From c600aec49e0057e6e2e22d3dee8ea59913a447c3 Mon Sep 17 00:00:00 2001 From: jannfis Date: Tue, 5 Apr 2022 18:38:43 +0200 Subject: [PATCH] chore: Make unit tests run on platforms other than amd64 (#8995) Signed-off-by: jannfis Co-authored-by: Michael Crenshaw Signed-off-by: wojtekidd --- cmd/argocd/commands/admin/project_allowlist_test.go | 6 ++++++ util/lua/custom_actions_test.go | 7 ------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cmd/argocd/commands/admin/project_allowlist_test.go b/cmd/argocd/commands/admin/project_allowlist_test.go index dea4d29297b9..0d57db932fda 100644 --- a/cmd/argocd/commands/admin/project_allowlist_test.go +++ b/cmd/argocd/commands/admin/project_allowlist_test.go @@ -2,6 +2,7 @@ package admin import ( "reflect" + "runtime" "testing" "github.com/stretchr/testify/assert" @@ -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{} diff --git a/util/lua/custom_actions_test.go b/util/lua/custom_actions_test.go index b530ffe4f588..3108ec5909e8 100644 --- a/util/lua/custom_actions_test.go +++ b/util/lua/custom_actions_test.go @@ -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" @@ -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.