build: fix make fmt
, reformat test sources (#234)
This commit is contained in:
7
Makefile
7
Makefile
@ -14,8 +14,11 @@ ifdef COMMIT
|
||||
endif
|
||||
export GO_BUILD=go build -ldflags "$(LDFLAGS)"
|
||||
|
||||
# SOURCES are the files that affect building the main binary.
|
||||
SOURCES := $(shell find . -name '*.go' -not -name '*_test.go') go.mod go.sum
|
||||
SOURCES_NO_VENDOR := $(shell find . -path ./vendor -prune -o -name "*.go" -not -name '*_test.go' -print)
|
||||
|
||||
# FMT_FILES are all files that should be formatted according to our rules.
|
||||
FMT_FILES := $(shell find . -path ./vendor -prune -o -name "*.go" -print)
|
||||
|
||||
# Allow for `go test` to be swapped out by other tooling, i.e. `gotestsum`
|
||||
export GO_TEST=go test
|
||||
@ -26,7 +29,7 @@ GO_TEST_PATHS=./...
|
||||
openapi:
|
||||
./etc/generate-openapi.sh
|
||||
|
||||
fmt: $(SOURCES_NO_VENDOR)
|
||||
fmt: $(FMT_FILES)
|
||||
# Format everything, but the import-format doesn't match our desired pattern.
|
||||
gofmt -w -s $^
|
||||
# Remove unused imports.
|
||||
|
@ -17,8 +17,8 @@ import (
|
||||
|
||||
const (
|
||||
defaultOrgName = "default org"
|
||||
fakeResults = "data data data"
|
||||
fakeKey = "key1"
|
||||
fakeResults = "data data data"
|
||||
fakeKey = "key1"
|
||||
)
|
||||
|
||||
func TestSecret_List(t *testing.T) {
|
||||
@ -29,12 +29,12 @@ func TestSecret_List(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
params secret.ListParams
|
||||
defaultOrgName string
|
||||
name string
|
||||
params secret.ListParams
|
||||
defaultOrgName string
|
||||
registerExpectations func(t *testing.T, secretApi *mock.MockSecretsApi, orgApi *mock.MockOrganizationsApi)
|
||||
expectMatcher string
|
||||
expectError string
|
||||
expectMatcher string
|
||||
expectError string
|
||||
}{
|
||||
{
|
||||
name: "org id",
|
||||
@ -50,7 +50,7 @@ func TestSecret_List(t *testing.T) {
|
||||
secretApi.EXPECT().GetOrgsIDSecretsExecute(gomock.Eq(req)).
|
||||
Return(api.SecretKeysResponse{Secrets: &[]string{fakeResults}}, nil)
|
||||
},
|
||||
expectMatcher: printHeader+fakeResults+"\t"+id.String()+"\n",
|
||||
expectMatcher: printHeader + fakeResults + "\t" + id.String() + "\n",
|
||||
},
|
||||
{
|
||||
name: "default org",
|
||||
@ -102,7 +102,7 @@ func TestSecret_List(t *testing.T) {
|
||||
},
|
||||
StdIO: stdio,
|
||||
},
|
||||
SecretsApi: secretsApi,
|
||||
SecretsApi: secretsApi,
|
||||
OrganizationsApi: organizationsApi,
|
||||
}
|
||||
|
||||
@ -126,12 +126,12 @@ func TestSecret_Delete(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
params secret.DeleteParams
|
||||
defaultOrgName string
|
||||
name string
|
||||
params secret.DeleteParams
|
||||
defaultOrgName string
|
||||
registerExpectations func(t *testing.T, secretApi *mock.MockSecretsApi)
|
||||
expectMatcher string
|
||||
expectError string
|
||||
expectMatcher string
|
||||
expectError string
|
||||
}{
|
||||
{
|
||||
name: "delete",
|
||||
@ -139,7 +139,7 @@ func TestSecret_Delete(t *testing.T) {
|
||||
OrgParams: clients.OrgParams{
|
||||
OrgID: id,
|
||||
},
|
||||
Key: fakeKey,
|
||||
Key: fakeKey,
|
||||
},
|
||||
defaultOrgName: defaultOrgName,
|
||||
registerExpectations: func(t *testing.T, secretApi *mock.MockSecretsApi) {
|
||||
@ -149,7 +149,7 @@ func TestSecret_Delete(t *testing.T) {
|
||||
secretApi.EXPECT().PostOrgsIDSecrets(gomock.Any(), gomock.Eq(id.String())).Return(req)
|
||||
secretApi.EXPECT().PostOrgsIDSecretsExecute(gomock.Eq(req)).Return(nil)
|
||||
},
|
||||
expectMatcher: printHeader+fakeKey+"\t"+id.String()+"\ttrue\n",
|
||||
expectMatcher: printHeader + fakeKey + "\t" + id.String() + "\ttrue\n",
|
||||
},
|
||||
{
|
||||
// This situation cannot happen since the CLI will stop it.
|
||||
@ -168,7 +168,7 @@ func TestSecret_Delete(t *testing.T) {
|
||||
secretApi.EXPECT().PostOrgsIDSecrets(gomock.Any(), gomock.Eq(id.String())).Return(req)
|
||||
secretApi.EXPECT().PostOrgsIDSecretsExecute(gomock.Eq(req)).Return(nil)
|
||||
},
|
||||
expectMatcher: printHeader+"\t"+id.String()+"\ttrue\n",
|
||||
expectMatcher: printHeader + "\t" + id.String() + "\ttrue\n",
|
||||
},
|
||||
{
|
||||
name: "delete no org",
|
||||
@ -224,12 +224,12 @@ func TestSecret_Update(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
params secret.UpdateParams
|
||||
defaultOrgName string
|
||||
name string
|
||||
params secret.UpdateParams
|
||||
defaultOrgName string
|
||||
registerExpectations func(t *testing.T, secretApi *mock.MockSecretsApi, stdio *mock.MockStdIO)
|
||||
expectMatcher string
|
||||
expectError string
|
||||
expectMatcher string
|
||||
expectError string
|
||||
}{
|
||||
{
|
||||
name: "update",
|
||||
@ -237,8 +237,8 @@ func TestSecret_Update(t *testing.T) {
|
||||
OrgParams: clients.OrgParams{
|
||||
OrgID: id,
|
||||
},
|
||||
Key: fakeKey,
|
||||
Value: fakeValue,
|
||||
Key: fakeKey,
|
||||
Value: fakeValue,
|
||||
},
|
||||
defaultOrgName: defaultOrgName,
|
||||
registerExpectations: func(t *testing.T, secretApi *mock.MockSecretsApi, stdio *mock.MockStdIO) {
|
||||
@ -248,7 +248,7 @@ func TestSecret_Update(t *testing.T) {
|
||||
secretApi.EXPECT().PatchOrgsIDSecrets(gomock.Any(), gomock.Eq(id.String())).Return(req)
|
||||
secretApi.EXPECT().PatchOrgsIDSecretsExecute(gomock.Eq(req)).Return(nil)
|
||||
},
|
||||
expectMatcher: printHeader+fakeKey+"\t"+id.String()+"\n",
|
||||
expectMatcher: printHeader + fakeKey + "\t" + id.String() + "\n",
|
||||
},
|
||||
{
|
||||
name: "update no key",
|
||||
@ -256,7 +256,7 @@ func TestSecret_Update(t *testing.T) {
|
||||
OrgParams: clients.OrgParams{
|
||||
OrgID: id,
|
||||
},
|
||||
Value: fakeValue,
|
||||
Value: fakeValue,
|
||||
},
|
||||
defaultOrgName: defaultOrgName,
|
||||
registerExpectations: func(t *testing.T, secretApi *mock.MockSecretsApi, stdio *mock.MockStdIO) {
|
||||
@ -266,7 +266,7 @@ func TestSecret_Update(t *testing.T) {
|
||||
secretApi.EXPECT().PatchOrgsIDSecrets(gomock.Any(), gomock.Eq(id.String())).Return(req)
|
||||
secretApi.EXPECT().PatchOrgsIDSecretsExecute(gomock.Eq(req)).Return(nil)
|
||||
},
|
||||
expectMatcher: printHeader+"\t"+id.String()+"\n",
|
||||
expectMatcher: printHeader + "\t" + id.String() + "\n",
|
||||
},
|
||||
{
|
||||
name: "update no value",
|
||||
@ -274,7 +274,7 @@ func TestSecret_Update(t *testing.T) {
|
||||
OrgParams: clients.OrgParams{
|
||||
OrgID: id,
|
||||
},
|
||||
Key: fakeKey,
|
||||
Key: fakeKey,
|
||||
},
|
||||
defaultOrgName: defaultOrgName,
|
||||
registerExpectations: func(t *testing.T, secretApi *mock.MockSecretsApi, stdio *mock.MockStdIO) {
|
||||
@ -286,7 +286,7 @@ func TestSecret_Update(t *testing.T) {
|
||||
secretApi.EXPECT().PatchOrgsIDSecrets(gomock.Any(), gomock.Eq(id.String())).Return(req)
|
||||
secretApi.EXPECT().PatchOrgsIDSecretsExecute(gomock.Eq(req)).Return(nil)
|
||||
},
|
||||
expectMatcher: printHeader+fakeKey+"\t"+id.String()+"\n",
|
||||
expectMatcher: printHeader + fakeKey + "\t" + id.String() + "\n",
|
||||
},
|
||||
{
|
||||
name: "update no org",
|
||||
|
@ -24,9 +24,9 @@ func TestNormalize(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "github URL with extensions",
|
||||
in: url.URL{Host: "github.com", Path: "/influxdata/community-templates/blob/master/github/github.yml"},
|
||||
in: url.URL{Host: "github.com", Path: "/influxdata/community-templates/blob/master/github/github.yml"},
|
||||
exts: []string{".yaml", ".yml", ".jsonnet", ".json"},
|
||||
out: url.URL{Host: "raw.githubusercontent.com", Path: "/influxdata/community-templates/master/github/github.yml"},
|
||||
out: url.URL{Host: "raw.githubusercontent.com", Path: "/influxdata/community-templates/master/github/github.yml"},
|
||||
},
|
||||
{
|
||||
name: "other URL",
|
||||
|
@ -51,7 +51,7 @@ func TestGzipPipe(t *testing.T) {
|
||||
}
|
||||
|
||||
type failingReader struct {
|
||||
n int
|
||||
n int
|
||||
err error
|
||||
}
|
||||
|
||||
|
@ -427,8 +427,8 @@ spec:
|
||||
tmpl, err := source.Read(context.Background())
|
||||
require.NoError(t, err)
|
||||
expected := api.TemplateApplyTemplate{
|
||||
Sources: []string{source.Name},
|
||||
Contents: parsed,
|
||||
Sources: []string{source.Name},
|
||||
Contents: parsed,
|
||||
}
|
||||
require.Equal(t, expected, tmpl)
|
||||
})
|
||||
|
Reference in New Issue
Block a user