Skip to content

Commit 7b013f8

Browse files
committed
Make test independent of OS
The github CLI runs on linux which was the reason why the pipeline failed. The file was not served because the target URL was not correct for a linux system.
1 parent 3782160 commit 7b013f8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cmd/update_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ package cmd
22

33
import (
44
"bytes"
5+
"fmt"
56
"github.com/stretchr/testify/assert"
67
"log"
78
"net/http"
89
"net/http/httptest"
910
"os"
1011
"rockstaedt/commit-message-check/internal/model"
12+
"runtime"
1113
"testing"
1214
)
1315

@@ -121,7 +123,8 @@ func TestDownloadScript(t *testing.T) {
121123
err := os.WriteFile(tempDir+"/dummy", []byte("i am a go binary"), os.ModePerm)
122124
assert.Nil(t, err)
123125
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
124-
if r.URL.String() == "/commit-message-check-v1.1.1-darwin-amd64" {
126+
targetUrl := fmt.Sprintf("/commit-message-check-v1.1.1-%s-%s", runtime.GOOS, runtime.GOARCH)
127+
if r.URL.String() == targetUrl {
125128
http.ServeFile(w, r, tempDir+"/dummy")
126129
}
127130
}))

0 commit comments

Comments
 (0)