Skip to content

Commit

Permalink
chore: Make unit tests run on platforms other than amd64 (#8995)
Browse files Browse the repository at this point in the history
Signed-off-by: jannfis <jann@mistrust.net>

Co-authored-by: Michael Crenshaw <michael@crenshaw.dev>
Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>
  • Loading branch information
jannfis and crenshaw-dev committed Jun 13, 2022
1 parent dc8785e commit a923810
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
6 changes: 6 additions & 0 deletions cmd/argocd/commands/admin/project_allowlist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package admin

import (
"reflect"
"runtime"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -13,6 +14,11 @@ import (
)

func TestProjectAllowListGen(t *testing.T) {
// go-mpatch only works on platforms with amd64 architecture
if runtime.GOARCH != "amd64" {
t.Skip()
}

useMock := true
rules := clientcmd.NewDefaultClientConfigLoadingRules()
overrides := &clientcmd.ConfigOverrides{}
Expand Down
7 changes: 0 additions & 7 deletions util/lua/custom_actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import (
"path/filepath"
"strings"
"testing"
"time"

"github.com/undefinedlabs/go-mpatch"

"github.com/argoproj/gitops-engine/pkg/diff"
"github.com/ghodss/yaml"
Expand Down Expand Up @@ -87,13 +84,9 @@ func TestLuaResourceActionsScript(t *testing.T) {
action, err := vm.GetResourceAction(obj, test.Action)
assert.NoError(t, err)

// freeze time so that lua test has predictable time output (will return 0001-01-01T00:00:00Z)
patch, err := mpatch.PatchMethod(time.Now, func() time.Time { return time.Time{} })
assert.NoError(t, err)
result, err := vm.ExecuteResourceAction(obj, action.ActionLua)
assert.NoError(t, err)
err = patch.Unpatch()
assert.NoError(t, err)

expectedObj := getObj(filepath.Join(dir, test.ExpectedOutputPath))
// Ideally, we would use a assert.Equal to detect the difference, but the Lua VM returns a object with float64 instead of the original int32. As a result, the assert.Equal is never true despite that the change has been applied.
Expand Down

0 comments on commit a923810

Please sign in to comment.