Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
package elasticsearch
import (
"io"
"os"
"testing"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v3"
"github.com/bytebase/bytebase/backend/common/yamltest"
)
func TestParseElasticsearchREST(t *testing.T) {
type testCase struct {
Description string `yaml:"description,omitempty"`
Statement string `yaml:"statement,omitempty"`
Result *ParseResult `yaml:"result,omitempty"`
}
var (
filepath = "test-data/parse-elasticsearch-rest.yaml"
record = false
)
a := require.New(t)
yamlFile, err := os.Open(filepath)
a.NoError(err)
byteValue, err := io.ReadAll(yamlFile)
a.NoError(err)
a.NoError(yamlFile.Close())
var testCases []testCase
a.NoError(yaml.Unmarshal(byteValue, &testCases))
for i, tc := range testCases {
got, err := ParseElasticsearchREST(tc.Statement)
a.NoErrorf(err, "description: %s", tc.Description)
if record {
testCases[i].Result = got
} else {
a.Equalf(tc.Result, got, "description: %s", tc.Description)
}
}
if record {
yamltest.Record(t, filepath, testCases)
}
}