Skip to content

Commit b81db09

Browse files
author
Roberto Sora
committed
finalize helpers_test User-Agent header value
1 parent e733627 commit b81db09

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

arduino/resources/helpers_test.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@ import (
2222
"io/ioutil"
2323
"net/http"
2424
"net/http/httptest"
25-
"runtime"
2625
"strings"
2726
"testing"
2827

29-
"github.com/arduino/arduino-cli/version"
3028
"github.com/arduino/go-paths-helper"
3129
"github.com/stretchr/testify/require"
3230
)
@@ -39,9 +37,8 @@ func (h *EchoHandler) ServeHTTP(writer http.ResponseWriter, request *http.Reques
3937
}
4038

4139
func TestDownloadApplyUserAgentHeaderUsingConfig(t *testing.T) {
42-
userAgentValue := fmt.Sprintf("%s/%s (%s; %s; %s) Commit:%s/Build:%s", version.GetApplication(),
43-
version.GetVersion(), runtime.GOARCH, runtime.GOOS, runtime.Version(), version.GetCommit(), version.GetBuildDate())
44-
goldUserAgentString := "User-Agent: " + userAgentValue
40+
goldUserAgentValue := fmt.Sprintf("arduino-cli/0.0.0-test.preview (amd64; linux; go1.12.4) Commit:deadbeef/Build:2019-06-12 11:11:11.111")
41+
goldUserAgentString := "User-Agent: " + goldUserAgentValue
4542

4643
tmp, err := paths.MkTempDir("", "")
4744
require.NoError(t, err)
@@ -57,7 +54,7 @@ func TestDownloadApplyUserAgentHeaderUsingConfig(t *testing.T) {
5754
URL: srv.URL,
5855
}
5956

60-
d, err := r.Download(tmp, http.Header{"User-Agent": []string{userAgentValue}})
57+
d, err := r.Download(tmp, http.Header{"User-Agent": []string{goldUserAgentValue}})
6158
require.NoError(t, err)
6259
err = d.Run()
6360
require.NoError(t, err)
@@ -67,7 +64,7 @@ func TestDownloadApplyUserAgentHeaderUsingConfig(t *testing.T) {
6764
// expect something like:
6865
// GET /echo HTTP/1.1
6966
// Host: 127.0.0.1:64999
70-
// User-Agent: arduino-cli/0.3.6-alpha.preview (amd64; linux; go1.10) Commit:missing/Build:missing
67+
// User-Agent: arduino-cli/0.0.0-test.preview (amd64; linux; go1.12.4) Commit:deadbeef/Build:2019-06-12 11:11:11.111
7168
// Accept-Encoding: gzip
7269

7370
b, err := ioutil.ReadFile(tmp.String() + "/cache/echo.txt") // just pass the file name

0 commit comments

Comments
 (0)