From dd2ca4e2733defabf4d1b41b72f7d36cbef8f2b0 Mon Sep 17 00:00:00 2001 From: Joonas Loppi Date: Sat, 20 May 2023 13:43:19 +0300 Subject: [PATCH] remove tests that require generics (Go doesn't allow me to bump lang version) closes #57 --- cmd/bob/bobfile_test.go | 65 ------------------------------------- pkg/dockertag/parse_test.go | 58 --------------------------------- 2 files changed, 123 deletions(-) delete mode 100644 cmd/bob/bobfile_test.go delete mode 100644 pkg/dockertag/parse_test.go diff --git a/cmd/bob/bobfile_test.go b/cmd/bob/bobfile_test.go deleted file mode 100644 index 8f86da7..0000000 --- a/cmd/bob/bobfile_test.go +++ /dev/null @@ -1,65 +0,0 @@ -package main - -import ( - "testing" - - "github.com/function61/gokit/testing/assert" -) - -func TestAssertUniqueBuilderNames(t *testing.T) { - bobfileEmpty := &Bobfile{} - bobfileUniques := &Bobfile{ - Builders: []BuilderSpec{ - { - Name: "default", - }, - { - Name: "foobar", - }, - }, - } - bobfileNonUniques := &Bobfile{ - Builders: []BuilderSpec{ - { - Name: "foobar", - }, - { - Name: "foobar", - }, - }, - } - - assert.Ok(t, validateBuilders(bobfileEmpty)) - assert.Ok(t, validateBuilders(bobfileUniques)) - assert.Equal(t, validateBuilders(bobfileNonUniques).Error(), "duplicate builder name: foobar") -} - -func TestConsentToBreakage(t *testing.T) { - properConsent := &Bobfile{ - Builders: []BuilderSpec{ - { - Name: "foobar", - Commands: BuilderCommands{ - Prepare: []string{"foo"}, - }, - }, - }, - Experiments: experiments{ - PrepareStep: true, - }, - } - - missingConsent := &Bobfile{ - Builders: []BuilderSpec{ - { - Name: "foobar", - Commands: BuilderCommands{ - Prepare: []string{"foo"}, - }, - }, - }, - } - - assert.Ok(t, validateBuilders(properConsent)) - assert.Equal(t, validateBuilders(missingConsent).Error(), "foobar: you need to opt-in to prepare_step experiment") -} diff --git a/pkg/dockertag/parse_test.go b/pkg/dockertag/parse_test.go deleted file mode 100644 index 2a3fe52..0000000 --- a/pkg/dockertag/parse_test.go +++ /dev/null @@ -1,58 +0,0 @@ -package dockertag - -import ( - "fmt" - "testing" - - "github.com/function61/gokit/testing/assert" -) - -func TestParseDockerTag(t *testing.T) { - assert.Equal( - t, - serialize(Parse("redis")), - "registry<> namespace<> repository tag<>") - - assert.Equal( - t, - serialize(Parse("redis:1.2.3.4")), - "registry<> namespace<> repository tag<1.2.3.4>") - - assert.Equal( - t, - serialize(Parse("joonas/redis:1.2.3.4")), - "registry<> namespace repository tag<1.2.3.4>") - - assert.Equal( - t, - serialize(Parse("docker.io/joonas/redis:1.2.3.4")), - "registry namespace repository tag<1.2.3.4>") - - assert.Equal( - t, - serialize(Parse("123456.dkr.ecr.us-east-1.amazonaws.com/joonas.fi-blog")), - "registry<123456.dkr.ecr.us-east-1.amazonaws.com> namespace<> repository tag<>") - - assert.Equal( - t, - serialize(Parse("registry.gitlab.com/function61/project/subcomponent:1.2.3.4")), - "registry namespace repository tag<1.2.3.4>") - - assert.Equal( - t, - serialize(Parse("")), - "(failed to parse)") -} - -func serialize(tag *Tag) string { - if tag == nil { - return "(failed to parse)" - } - - return fmt.Sprintf( - "registry<%s> namespace<%s> repository<%s> tag<%s>", - tag.Registry, - tag.Namespace, - tag.Repository, - tag.Tag) -}