Skip to content

Commit

Permalink
fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
tateexon committed Jul 31, 2024
1 parent 8425247 commit d31c8e7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions main_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"testing"

"github.com/stretchr/testify/require"
Expand All @@ -9,6 +10,13 @@ import (
"github.com/tateexon/go-change-delta/utils"
)

func verifySliceItemsPresent(t *testing.T, expected, actual []string) {
require.Equal(t, len(expected), len(actual), fmt.Sprintf("Expected: %+v\nActual: %+v\n", expected, actual))
for _, item := range expected {
require.Contains(t, actual, item)
}
}

func TestSetConfig(t *testing.T) {
config := setConfig(utils.Ptr("main"), utils.Ptr("abc"), utils.Ptr("abc,123"), utils.Ptr(1), utils.Ptr(true))
require.NotNil(t, config)
Expand Down Expand Up @@ -81,8 +89,10 @@ func TestFindAllAffectedPackages(t *testing.T) {

pkgs := findAllAffectedPackages(config, changedPackages, changedModPackages, depMap)
require.Equal(t, 2, len(pkgs))
require.Equal(t, "github.com/tateexon/go-change-delta/test", pkgs[0])
require.Equal(t, "github.com/tateexon/go-change-delta/two", pkgs[1])
verifySliceItemsPresent(t, []string{
"github.com/tateexon/go-change-delta/test",
"github.com/tateexon/go-change-delta/two",
}, pkgs)
})

t.Run("only changed go mod file", func(t *testing.T) {
Expand Down

0 comments on commit d31c8e7

Please sign in to comment.