Skip to content

Commit

Permalink
test: new group test helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
42atomys committed Nov 5, 2024
1 parent 190a27f commit c197b24
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 0 deletions.
34 changes: 34 additions & 0 deletions group/all/all_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package all_test

import (
"testing"

"github.com/go-sprout/sprout/group/all"
"github.com/go-sprout/sprout/pesticide"
)

func TestRegistryGroup(t *testing.T) {
tc := pesticide.GroupTestCase{
RegistriesUIDs: []string{
"go-sprout/sprout.checksum",
"go-sprout/sprout.conversion",
"go-sprout/sprout.encoding",
"go-sprout/sprout.env",
"go-sprout/sprout.filesystem",
"go-sprout/sprout.maps",
"go-sprout/sprout.network",
"go-sprout/sprout.numeric",
"go-sprout/sprout.random",
"go-sprout/sprout.reflect",
"go-sprout/sprout.regexp",
"go-sprout/sprout.semver",
"go-sprout/sprout.slices",
"go-sprout/sprout.std",
"go-sprout/sprout.strings",
"go-sprout/sprout.time",
"go-sprout/sprout.uniqueid",
},
}

pesticide.RunGroupTest(t, all.RegistryGroup(), tc)
}
31 changes: 31 additions & 0 deletions group/hermetic/hermetic_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package hermetic_test

import (
"testing"

"github.com/go-sprout/sprout/group/hermetic"
"github.com/go-sprout/sprout/pesticide"
)

func TestRegistryGroup(t *testing.T) {
tc := pesticide.GroupTestCase{
RegistriesUIDs: []string{
"go-sprout/sprout.checksum",
"go-sprout/sprout.conversion",
"go-sprout/sprout.encoding",
"go-sprout/sprout.filesystem",
"go-sprout/sprout.maps",
"go-sprout/sprout.numeric",
"go-sprout/sprout.reflect",
"go-sprout/sprout.regexp",
"go-sprout/sprout.semver",
"go-sprout/sprout.slices",
"go-sprout/sprout.std",
"go-sprout/sprout.strings",
"go-sprout/sprout.time",
"go-sprout/sprout.uniqueid",
},
}

pesticide.RunGroupTest(t, hermetic.RegistryGroup(), tc)
}
26 changes: 26 additions & 0 deletions pesticide/group_test_helpers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package pesticide

import (
"testing"

"github.com/go-sprout/sprout"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

type GroupTestCase struct {
RegistriesUIDs []string
}

func RunGroupTest(t *testing.T, rg *sprout.RegistryGroup, tc GroupTestCase) {
t.Helper()

require.NotNil(t, rg, "RegistryGroup should not be nil")
require.NotNil(t, rg.Registries, "RegistryGroup.Registries should not be nil")

require.Len(t, rg.Registries, len(tc.RegistriesUIDs), "The number of registries should match the number of expected registries")

for _, registry := range rg.Registries {
assert.Contains(t, tc.RegistriesUIDs, registry.UID(), "Registry UID %s aren't excepted", registry.UID())
}
}
File renamed without changes.

0 comments on commit c197b24

Please sign in to comment.