Skip to content

Commit

Permalink
Simpler tests
Browse files Browse the repository at this point in the history
Signed-off-by: David Gageot <david@gageot.net>
  • Loading branch information
dgageot committed May 29, 2019
1 parent 3fe9be7 commit aea09f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
14 changes: 4 additions & 10 deletions pkg/skaffold/apiversion/apiversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,20 @@ limitations under the License.
package apiversion

import (
"reflect"
"testing"

"github.com/GoogleContainerTools/skaffold/testutil"
"github.com/blang/semver"
)

func TestMustParse(t *testing.T) {
_ = MustParse("skaffold/v1alpha4")
MustParse("skaffold/v1alpha4")
}

func TestMustParse_panic(t *testing.T) {
defer testutil.EnsureTestPanicked(t)

_ = MustParse("invalid version")
MustParse("invalid version")
}

func TestParseVersion(t *testing.T) {
Expand Down Expand Up @@ -81,13 +80,8 @@ func TestParseVersion(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := Parse(tt.args.v)
if (err != nil) != tt.wantErr {
t.Errorf("Parse() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("Parse() = %v, want %v", got, tt.want)
}

testutil.CheckErrorAndDeepEqual(t, tt.wantErr, err, tt.want, got)
})
}
}
6 changes: 3 additions & 3 deletions pkg/skaffold/yamltags/tags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,11 @@ func TestValidateStructOneOf(t *testing.T) {
func TestValidateStructInvalid(t *testing.T) {
defer testutil.EnsureTestPanicked(t)

invalidYamlTags := struct {
invalidTags := struct {
A string `yamltags:"invalidTag"`
}{A: "whatever"}
}{}

_ = ValidateStruct(invalidYamlTags)
ValidateStruct(invalidTags)
}

func TestIsZeroValue(t *testing.T) {
Expand Down

0 comments on commit aea09f0

Please sign in to comment.