build: fix make fmt
, reformat test sources (#234)
This commit is contained in:
7
Makefile
7
Makefile
@ -14,8 +14,11 @@ ifdef COMMIT
|
|||||||
endif
|
endif
|
||||||
export GO_BUILD=go build -ldflags "$(LDFLAGS)"
|
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 := $(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`
|
# Allow for `go test` to be swapped out by other tooling, i.e. `gotestsum`
|
||||||
export GO_TEST=go test
|
export GO_TEST=go test
|
||||||
@ -26,7 +29,7 @@ GO_TEST_PATHS=./...
|
|||||||
openapi:
|
openapi:
|
||||||
./etc/generate-openapi.sh
|
./etc/generate-openapi.sh
|
||||||
|
|
||||||
fmt: $(SOURCES_NO_VENDOR)
|
fmt: $(FMT_FILES)
|
||||||
# Format everything, but the import-format doesn't match our desired pattern.
|
# Format everything, but the import-format doesn't match our desired pattern.
|
||||||
gofmt -w -s $^
|
gofmt -w -s $^
|
||||||
# Remove unused imports.
|
# Remove unused imports.
|
||||||
|
@ -17,8 +17,8 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
defaultOrgName = "default org"
|
defaultOrgName = "default org"
|
||||||
fakeResults = "data data data"
|
fakeResults = "data data data"
|
||||||
fakeKey = "key1"
|
fakeKey = "key1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSecret_List(t *testing.T) {
|
func TestSecret_List(t *testing.T) {
|
||||||
@ -29,12 +29,12 @@ func TestSecret_List(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
params secret.ListParams
|
params secret.ListParams
|
||||||
defaultOrgName string
|
defaultOrgName string
|
||||||
registerExpectations func(t *testing.T, secretApi *mock.MockSecretsApi, orgApi *mock.MockOrganizationsApi)
|
registerExpectations func(t *testing.T, secretApi *mock.MockSecretsApi, orgApi *mock.MockOrganizationsApi)
|
||||||
expectMatcher string
|
expectMatcher string
|
||||||
expectError string
|
expectError string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "org id",
|
name: "org id",
|
||||||
@ -50,7 +50,7 @@ func TestSecret_List(t *testing.T) {
|
|||||||
secretApi.EXPECT().GetOrgsIDSecretsExecute(gomock.Eq(req)).
|
secretApi.EXPECT().GetOrgsIDSecretsExecute(gomock.Eq(req)).
|
||||||
Return(api.SecretKeysResponse{Secrets: &[]string{fakeResults}}, nil)
|
Return(api.SecretKeysResponse{Secrets: &[]string{fakeResults}}, nil)
|
||||||
},
|
},
|
||||||
expectMatcher: printHeader+fakeResults+"\t"+id.String()+"\n",
|
expectMatcher: printHeader + fakeResults + "\t" + id.String() + "\n",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "default org",
|
name: "default org",
|
||||||
@ -102,7 +102,7 @@ func TestSecret_List(t *testing.T) {
|
|||||||
},
|
},
|
||||||
StdIO: stdio,
|
StdIO: stdio,
|
||||||
},
|
},
|
||||||
SecretsApi: secretsApi,
|
SecretsApi: secretsApi,
|
||||||
OrganizationsApi: organizationsApi,
|
OrganizationsApi: organizationsApi,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,12 +126,12 @@ func TestSecret_Delete(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
params secret.DeleteParams
|
params secret.DeleteParams
|
||||||
defaultOrgName string
|
defaultOrgName string
|
||||||
registerExpectations func(t *testing.T, secretApi *mock.MockSecretsApi)
|
registerExpectations func(t *testing.T, secretApi *mock.MockSecretsApi)
|
||||||
expectMatcher string
|
expectMatcher string
|
||||||
expectError string
|
expectError string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "delete",
|
name: "delete",
|
||||||
@ -139,7 +139,7 @@ func TestSecret_Delete(t *testing.T) {
|
|||||||
OrgParams: clients.OrgParams{
|
OrgParams: clients.OrgParams{
|
||||||
OrgID: id,
|
OrgID: id,
|
||||||
},
|
},
|
||||||
Key: fakeKey,
|
Key: fakeKey,
|
||||||
},
|
},
|
||||||
defaultOrgName: defaultOrgName,
|
defaultOrgName: defaultOrgName,
|
||||||
registerExpectations: func(t *testing.T, secretApi *mock.MockSecretsApi) {
|
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().PostOrgsIDSecrets(gomock.Any(), gomock.Eq(id.String())).Return(req)
|
||||||
secretApi.EXPECT().PostOrgsIDSecretsExecute(gomock.Eq(req)).Return(nil)
|
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.
|
// 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().PostOrgsIDSecrets(gomock.Any(), gomock.Eq(id.String())).Return(req)
|
||||||
secretApi.EXPECT().PostOrgsIDSecretsExecute(gomock.Eq(req)).Return(nil)
|
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",
|
name: "delete no org",
|
||||||
@ -224,12 +224,12 @@ func TestSecret_Update(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
params secret.UpdateParams
|
params secret.UpdateParams
|
||||||
defaultOrgName string
|
defaultOrgName string
|
||||||
registerExpectations func(t *testing.T, secretApi *mock.MockSecretsApi, stdio *mock.MockStdIO)
|
registerExpectations func(t *testing.T, secretApi *mock.MockSecretsApi, stdio *mock.MockStdIO)
|
||||||
expectMatcher string
|
expectMatcher string
|
||||||
expectError string
|
expectError string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "update",
|
name: "update",
|
||||||
@ -237,8 +237,8 @@ func TestSecret_Update(t *testing.T) {
|
|||||||
OrgParams: clients.OrgParams{
|
OrgParams: clients.OrgParams{
|
||||||
OrgID: id,
|
OrgID: id,
|
||||||
},
|
},
|
||||||
Key: fakeKey,
|
Key: fakeKey,
|
||||||
Value: fakeValue,
|
Value: fakeValue,
|
||||||
},
|
},
|
||||||
defaultOrgName: defaultOrgName,
|
defaultOrgName: defaultOrgName,
|
||||||
registerExpectations: func(t *testing.T, secretApi *mock.MockSecretsApi, stdio *mock.MockStdIO) {
|
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().PatchOrgsIDSecrets(gomock.Any(), gomock.Eq(id.String())).Return(req)
|
||||||
secretApi.EXPECT().PatchOrgsIDSecretsExecute(gomock.Eq(req)).Return(nil)
|
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",
|
name: "update no key",
|
||||||
@ -256,7 +256,7 @@ func TestSecret_Update(t *testing.T) {
|
|||||||
OrgParams: clients.OrgParams{
|
OrgParams: clients.OrgParams{
|
||||||
OrgID: id,
|
OrgID: id,
|
||||||
},
|
},
|
||||||
Value: fakeValue,
|
Value: fakeValue,
|
||||||
},
|
},
|
||||||
defaultOrgName: defaultOrgName,
|
defaultOrgName: defaultOrgName,
|
||||||
registerExpectations: func(t *testing.T, secretApi *mock.MockSecretsApi, stdio *mock.MockStdIO) {
|
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().PatchOrgsIDSecrets(gomock.Any(), gomock.Eq(id.String())).Return(req)
|
||||||
secretApi.EXPECT().PatchOrgsIDSecretsExecute(gomock.Eq(req)).Return(nil)
|
secretApi.EXPECT().PatchOrgsIDSecretsExecute(gomock.Eq(req)).Return(nil)
|
||||||
},
|
},
|
||||||
expectMatcher: printHeader+"\t"+id.String()+"\n",
|
expectMatcher: printHeader + "\t" + id.String() + "\n",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "update no value",
|
name: "update no value",
|
||||||
@ -274,7 +274,7 @@ func TestSecret_Update(t *testing.T) {
|
|||||||
OrgParams: clients.OrgParams{
|
OrgParams: clients.OrgParams{
|
||||||
OrgID: id,
|
OrgID: id,
|
||||||
},
|
},
|
||||||
Key: fakeKey,
|
Key: fakeKey,
|
||||||
},
|
},
|
||||||
defaultOrgName: defaultOrgName,
|
defaultOrgName: defaultOrgName,
|
||||||
registerExpectations: func(t *testing.T, secretApi *mock.MockSecretsApi, stdio *mock.MockStdIO) {
|
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().PatchOrgsIDSecrets(gomock.Any(), gomock.Eq(id.String())).Return(req)
|
||||||
secretApi.EXPECT().PatchOrgsIDSecretsExecute(gomock.Eq(req)).Return(nil)
|
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",
|
name: "update no org",
|
||||||
|
@ -24,9 +24,9 @@ func TestNormalize(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "github URL with extensions",
|
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"},
|
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",
|
name: "other URL",
|
||||||
|
@ -51,7 +51,7 @@ func TestGzipPipe(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type failingReader struct {
|
type failingReader struct {
|
||||||
n int
|
n int
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,8 +427,8 @@ spec:
|
|||||||
tmpl, err := source.Read(context.Background())
|
tmpl, err := source.Read(context.Background())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
expected := api.TemplateApplyTemplate{
|
expected := api.TemplateApplyTemplate{
|
||||||
Sources: []string{source.Name},
|
Sources: []string{source.Name},
|
||||||
Contents: parsed,
|
Contents: parsed,
|
||||||
}
|
}
|
||||||
require.Equal(t, expected, tmpl)
|
require.Equal(t, expected, tmpl)
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user