Skip to content

Commit

Permalink
test: fix interop test when running on CI push event.
Browse files Browse the repository at this point in the history
Signed-off-by: i4k <[email protected]>
  • Loading branch information
i4ki committed Sep 27, 2024
1 parent 7df5a19 commit 5c68981
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions e2etests/cloud/interop/interoperability_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package interop_test

import (
"encoding/json"
"fmt"
"os"
"path"
Expand All @@ -26,9 +27,23 @@ func TestInteropCloudSyncPreview(t *testing.T) {
} {
t.Run("preview: "+path.Base(stackpath), func(t *testing.T) {
env := os.Environ()
if os.Getenv("GITHUB_EVENT_PATH") == "" {
env = append(env, fmt.Sprintf("GITHUB_EVENT_PATH=%s", datapath(t, "testdata/event_pull_request.json")))

eventFile := os.Getenv("GITHUB_EVENT_PATH")
if eventFile != "" {
// check if exported GITHUB_EVENT_FILE is of type `pull_request`
var obj map[string]interface{}
content, err := os.ReadFile(eventFile)
assert.NoError(t, err)
assert.NoError(t, json.Unmarshal(content, &obj))
if obj["pull_request"] == nil {
eventFile = ""
}
}
if eventFile == "" {
eventFile = datapath(t, "testdata/event_pull_request.json")
env = append(env, fmt.Sprintf("GITHUB_EVENT_PATH=%s", eventFile))
}
t.Logf("using GITHUB_EVENT_FILE=%s", eventFile)
env = append(env, "GITHUB_ACTIONS=1")
tmcli := NewInteropCLI(t, datapath(t, stackpath), env...)
AssertRunResult(t,
Expand Down

0 comments on commit 5c68981

Please sign in to comment.