@@ -22,11 +22,9 @@ import (
22
22
"io/ioutil"
23
23
"net/http"
24
24
"net/http/httptest"
25
- "runtime"
26
25
"strings"
27
26
"testing"
28
27
29
- "github.com/arduino/arduino-cli/version"
30
28
"github.com/arduino/go-paths-helper"
31
29
"github.com/stretchr/testify/require"
32
30
)
@@ -39,9 +37,8 @@ func (h *EchoHandler) ServeHTTP(writer http.ResponseWriter, request *http.Reques
39
37
}
40
38
41
39
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
45
42
46
43
tmp , err := paths .MkTempDir ("" , "" )
47
44
require .NoError (t , err )
@@ -57,7 +54,7 @@ func TestDownloadApplyUserAgentHeaderUsingConfig(t *testing.T) {
57
54
URL : srv .URL ,
58
55
}
59
56
60
- d , err := r .Download (tmp , http.Header {"User-Agent" : []string {userAgentValue }})
57
+ d , err := r .Download (tmp , http.Header {"User-Agent" : []string {goldUserAgentValue }})
61
58
require .NoError (t , err )
62
59
err = d .Run ()
63
60
require .NoError (t , err )
@@ -67,7 +64,7 @@ func TestDownloadApplyUserAgentHeaderUsingConfig(t *testing.T) {
67
64
// expect something like:
68
65
// GET /echo HTTP/1.1
69
66
// 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
71
68
// Accept-Encoding: gzip
72
69
73
70
b , err := ioutil .ReadFile (tmp .String () + "/cache/echo.txt" ) // just pass the file name
0 commit comments