Skip to content

Commit

Permalink
Code format (#2519)
Browse files Browse the repository at this point in the history
* Declare all test cases the same way

Signed-off-by: David Gageot <david@gageot.net>

* Remove empty lines

Signed-off-by: David Gageot <david@gageot.net>

* Don’t use var

Signed-off-by: David Gageot <david@gageot.net>

* Fix comments

Signed-off-by: David Gageot <david@gageot.net>
  • Loading branch information
dgageot authored Jul 22, 2019
1 parent 6ddb860 commit 0712494
Show file tree
Hide file tree
Showing 75 changed files with 118 additions and 130 deletions.
6 changes: 3 additions & 3 deletions cmd/skaffold/app/cmd/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestQuietFlag(t *testing.T) {
return &mockRunner{}, &latest.SkaffoldConfig{}, nil
}

var tests = []struct {
tests := []struct {
description string
template string
expectedOutput []byte
Expand Down Expand Up @@ -99,7 +99,7 @@ func TestFileOutputFlag(t *testing.T) {
return &mockRunner{}, &latest.SkaffoldConfig{}, nil
}

var tests = []struct {
tests := []struct {
description string
filename string
quietFlag bool
Expand Down Expand Up @@ -163,7 +163,7 @@ func TestRunBuild(t *testing.T) {
return &mockRunner{}, &latest.SkaffoldConfig{}, nil
}

var tests = []struct {
tests := []struct {
description string
mock func(opts *config.SkaffoldOptions) (runner.Runner, *latest.SkaffoldConfig, error)
shouldErr bool
Expand Down
4 changes: 2 additions & 2 deletions cmd/skaffold/app/cmd/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var baseConfig = &Config{
var emptyConfig = &Config{}

func TestReadConfig(t *testing.T) {
var tests = []struct {
tests := []struct {
description string
filename string
expectedCfg *Config
Expand Down Expand Up @@ -77,7 +77,7 @@ func TestReadConfig(t *testing.T) {
func TestSetAndUnsetConfig(t *testing.T) {
dummyContext := "dummy_context"

var tests = []struct {
tests := []struct {
expectedSetCfg *Config
expectedUnsetCfg *Config
description string
Expand Down
2 changes: 1 addition & 1 deletion cmd/skaffold/app/flags/build_output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestNewBuildOutputFlag(t *testing.T) {
}

func TestBuildOutputSet(t *testing.T) {
var tests = []struct {
tests := []struct {
description string
files map[string]string
shouldErr bool
Expand Down
4 changes: 2 additions & 2 deletions cmd/skaffold/app/flags/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestNewEmptyImage(t *testing.T) {
}

func TestImagesFlagSet(t *testing.T) {
var tests = []struct {
tests := []struct {
description string
setValue string
shouldErr bool
Expand Down Expand Up @@ -117,7 +117,7 @@ func TestImagesType(t *testing.T) {
}

func TestConvertToArtifact(t *testing.T) {
var tests = []struct {
tests := []struct {
description string
image string
expected *build.Artifact
Expand Down
2 changes: 1 addition & 1 deletion cmd/skaffold/app/flags/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func NewTemplateFlag(value string, context interface{}) *TemplateFlag {
}

func parseTemplate(value string) (*template.Template, error) {
var funcs = template.FuncMap{
funcs := template.FuncMap{
"json": func(v interface{}) string {
buf := &bytes.Buffer{}
enc := json.NewEncoder(buf)
Expand Down
1 change: 0 additions & 1 deletion examples/microservices/leeroy-web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ func handler(w http.ResponseWriter, r *http.Request) {
if _, err := io.Copy(w, resp.Body); err != nil {
panic(err)
}

}

func main() {
Expand Down
6 changes: 3 additions & 3 deletions hack/schemas/testdata/inline-anyof/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ type TestStruct struct {
InlineOneOfStruct `yaml:"inline"`
}

//InlineOneOfStruct is embedded inline into TestStruct
// InlineOneOfStruct is embedded inline into TestStruct
type InlineOneOfStruct struct {

//Field1 should be the first choice
// Field1 should be the first choice
Field1 string `yaml:"field1" yamltags:"oneOf=fooBar"`

//Field2 should be the second choice
// Field2 should be the second choice
Field2 string `yaml:"field2" yamltags:"oneOf=fooBar"`
}
12 changes: 6 additions & 6 deletions hack/schemas/testdata/inline-hybrid/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ type TestStruct struct {
InlineOneOfStructAnyOf `yaml:"inline"`
}

//InlineOneOfStruct is embedded inline into TestStruct
// InlineOneOfStruct is embedded inline into TestStruct
type InlineOneOfStruct struct {

//Field1 should be the first choice
// Field1 should be the first choice
Field1 string `yaml:"f1"`

//Field2 should be the second choice
// Field2 should be the second choice
Field2 string `yaml:"f2"`
}

//InlineOneOfStructAnyOf is embedded inline into TestStruct
// InlineOneOfStructAnyOf is embedded inline into TestStruct
type InlineOneOfStructAnyOf struct {

//Choice1 should be the first choice
// Choice1 should be the first choice
Choice1 string `yaml:"choice1" yamltags:"oneOf=fooBar"`

//Choice2 should be the second choice
// Choice2 should be the second choice
Choice2 string `yaml:"choice2" yamltags:"oneOf=fooBar"`
}
2 changes: 1 addition & 1 deletion integration/dev_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
)

func TestDev(t *testing.T) {
var tests = []struct {
tests := []struct {
description string
trigger string
}{
Expand Down
1 change: 0 additions & 1 deletion integration/examples/microservices/leeroy-web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ func handler(w http.ResponseWriter, r *http.Request) {
if _, err := io.Copy(w, resp.Body); err != nil {
panic(err)
}

}

func main() {
Expand Down
2 changes: 1 addition & 1 deletion integration/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func TestEventLogRPC(t *testing.T) {
}

func TestEventLogHTTP(t *testing.T) {
var tests = []struct {
tests := []struct {
description string
endpoint string
}{
Expand Down
2 changes: 1 addition & 1 deletion integration/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
)

func TestDevSync(t *testing.T) {
var tests = []struct {
tests := []struct {
description string
trigger string
}{
Expand Down
1 change: 0 additions & 1 deletion integration/testdata/init/microservices/leeroy-web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ func handler(w http.ResponseWriter, r *http.Request) {
if _, err := io.Copy(w, resp.Body); err != nil {
panic(err)
}

}

func main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ func handler(w http.ResponseWriter, r *http.Request) {
if _, err := io.Copy(w, resp.Body); err != nil {
panic(err)
}

}

func main() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/build/bazel/dependencies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func TestQuery(t *testing.T) {
}

func TestDepToPath(t *testing.T) {
var tests = []struct {
tests := []struct {
description string
dep string
expected string
Expand Down
1 change: 0 additions & 1 deletion pkg/skaffold/build/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func TestRetrieveEnv(t *testing.T) {
},
},
})

if err != nil {
t.Fatalf("err retrieving builder: %v", err)
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/skaffold/build/custom/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (

// GetDependencies returns dependencies listed for a custom artifact
func GetDependencies(ctx context.Context, workspace string, a *latest.CustomArtifact, insecureRegistries map[string]bool) ([]string, error) {

switch {
case a.Dependencies.Dockerfile != nil:
dockerfile := a.Dependencies.Dockerfile
Expand Down Expand Up @@ -62,5 +61,4 @@ func GetDependencies(ctx context.Context, workspace string, a *latest.CustomArti
sort.Strings(dependencies)
return dependencies, nil
}

}
4 changes: 2 additions & 2 deletions pkg/skaffold/build/gcb/jib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
)

func TestJibMavenBuildSteps(t *testing.T) {
var tests = []struct {
tests := []struct {
skipTests bool
args []string
}{
Expand Down Expand Up @@ -59,7 +59,7 @@ func TestJibMavenBuildSteps(t *testing.T) {
}

func TestJibGradleBuildSteps(t *testing.T) {
var tests = []struct {
tests := []struct {
skipTests bool
args []string
}{
Expand Down
4 changes: 2 additions & 2 deletions pkg/skaffold/build/local/bazel.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func bazelBin(ctx context.Context, workspace string, a *latest.BazelArtifact) (s
}

func trimTarget(buildTarget string) string {
//TODO(r2d4): strip off leading //:, bad
// TODO(r2d4): strip off leading //:, bad
trimmedTarget := strings.TrimPrefix(buildTarget, "//")
// Useful if root target "//:target"
trimmedTarget = strings.TrimPrefix(trimmedTarget, ":")
Expand All @@ -117,7 +117,7 @@ func buildImageTag(buildTarget string) string {
imageTag := trimTarget(buildTarget)
imageTag = strings.TrimPrefix(imageTag, ":")

//TODO(r2d4): strip off trailing .tar, even worse
// TODO(r2d4): strip off trailing .tar, even worse
imageTag = strings.TrimSuffix(imageTag, ".tar")

if strings.Contains(imageTag, ":") {
Expand Down
4 changes: 2 additions & 2 deletions pkg/skaffold/build/local/jib_gradle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
)

func TestBuildJibGradleToDocker(t *testing.T) {
var tests = []struct {
tests := []struct {
description string
artifact *latest.JibGradleArtifact
cmd util.Command
Expand Down Expand Up @@ -85,7 +85,7 @@ func TestBuildJibGradleToDocker(t *testing.T) {
}

func TestBuildJibGradleToRegistry(t *testing.T) {
var tests = []struct {
tests := []struct {
description string
artifact *latest.JibGradleArtifact
cmd util.Command
Expand Down
6 changes: 3 additions & 3 deletions pkg/skaffold/build/local/jib_maven_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
)

func TestBuildJibMavenToDocker(t *testing.T) {
var tests = []struct {
tests := []struct {
description string
artifact *latest.JibMavenArtifact
cmd util.Command
Expand Down Expand Up @@ -101,7 +101,7 @@ func TestBuildJibMavenToDocker(t *testing.T) {
}

func TestBuildJibMavenToRegistry(t *testing.T) {
var tests = []struct {
tests := []struct {
description string
artifact *latest.JibMavenArtifact
cmd util.Command
Expand Down Expand Up @@ -175,7 +175,7 @@ func TestBuildJibMavenToRegistry(t *testing.T) {
}

func TestMavenVerifyJibPackageGoal(t *testing.T) {
var tests = []struct {
tests := []struct {
description string
requiredGoal string
mavenOutput string
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/build/local/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (t testAuthHelper) GetAuthConfig(string) (types.AuthConfig, error) {
func (t testAuthHelper) GetAllAuthConfigs() (map[string]types.AuthConfig, error) { return nil, nil }

func TestLocalRun(t *testing.T) {
var tests = []struct {
tests := []struct {
description string
api testutil.FakeAPIClient
tags tag.ImageTags
Expand Down
10 changes: 5 additions & 5 deletions pkg/skaffold/build/parallel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
)

func TestGetBuild(t *testing.T) {
var tests = []struct {
tests := []struct {
description string
buildArtifact artifactBuilder
tags tag.ImageTags
Expand Down Expand Up @@ -85,7 +85,7 @@ func TestGetBuild(t *testing.T) {
}

func TestCollectResults(t *testing.T) {
var tests = []struct {
tests := []struct {
description string
artifacts []*latest.Artifact
expected []Artifact
Expand Down Expand Up @@ -194,7 +194,7 @@ func TestCollectResults(t *testing.T) {
}

func TestInParallel(t *testing.T) {
var tests = []struct {
tests := []struct {
description string
buildFunc artifactBuilder
expected string
Expand Down Expand Up @@ -243,7 +243,7 @@ And new lines
}

func TestInParallelForArgs(t *testing.T) {
var tests = []struct {
tests := []struct {
description string
inSeqFunc func(context.Context, io.Writer, tag.ImageTags, []*latest.Artifact, artifactBuilder) ([]Artifact, error)
buildArtifact artifactBuilder
Expand Down Expand Up @@ -296,7 +296,7 @@ func TestInParallelForArgs(t *testing.T) {
}

func TestColoredOutput(t *testing.T) {
var tests = []struct {
tests := []struct {
description string
isTerminal func(w io.Writer) bool
exceptedColor bool
Expand Down
4 changes: 2 additions & 2 deletions pkg/skaffold/build/sequence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
)

func TestInSequence(t *testing.T) {
var tests = []struct {
tests := []struct {
description string
buildArtifact artifactBuilder
tags tag.ImageTags
Expand Down Expand Up @@ -89,7 +89,7 @@ func TestInSequence(t *testing.T) {
}

func TestInSequenceResultsOrder(t *testing.T) {
var tests = []struct {
tests := []struct {
description string
images []string
expected []Artifact
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/build/tag/date_time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestDateTime_GenerateFullyQualifiedImageName(t *testing.T) {
aLocalTimeStamp := time.Date(2015, 03, 07, 11, 06, 39, 123456789, time.Local)
localZone, _ := aLocalTimeStamp.Zone()

var tests = []struct {
tests := []struct {
description string
format string
buildTime time.Time
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/config/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func TestLabels(t *testing.T) {
}

func TestIsTargetImage(t *testing.T) {
var tests = []struct {
tests := []struct {
description string
targetImages []string
expectedMatch bool
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/debug/transform_python.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func extractPtvsdArg(args []string) *ptvsdSpec {
return nil
}
port, err := strconv.ParseInt(args[i+1], 10, 32)
//spec.port, err := strconv.Atoi(args[i+1])
// spec.port, err := strconv.Atoi(args[i+1])
if err != nil {
logrus.Errorf("Invalid python ptvsd port %q: %s\n", args[i+1], err)
return nil
Expand Down
Loading

0 comments on commit 0712494

Please sign in to comment.