This repository was archived by the owner on Mar 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalysis_test.go
More file actions
74 lines (67 loc) · 1.41 KB
/
Copy pathanalysis_test.go
File metadata and controls
74 lines (67 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package main
import (
"debug/elf"
"net/http"
"net/http/httptest"
"testing"
)
func compareSizes(t *testing.T, expect, got Size) {
if expect.Text != got.Text {
t.Errorf("expected text size %d got %d", expect.Text, got.Text)
}
if expect.Data != got.Data {
t.Errorf("expected data size %d got %d", expect.Data, got.Data)
}
if expect.Bss != got.Bss {
t.Errorf("expected bss size %d got %d", expect.Bss, got.Bss)
}
}
func TestNewMeasurements(t *testing.T) {
tests := map[string]struct {
size Size
}{
"rgctl.elf": {
Size{
Text: 940,
Data: 2,
Bss: 6,
},
},
"square.elf": {
Size{
Text: 1699,
Data: 616,
Bss: 8,
},
},
}
for name, test := range tests {
t.Run(name, func(t *testing.T) {
file, _ := elf.Open("testdata/" + name)
compareSizes(
t,
test.size,
newSize(file),
)
})
}
}
func TestPushRedirect(t *testing.T) {
path := "/api/analysis"
server := httptest.NewServer(http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
if request.URL.Path == path {
http.Redirect(writer, request, "/ok", 302)
}
if request.URL.Path == "/ok" {
writer.WriteHeader(200)
}
}))
t.Cleanup(func() { server.Close() })
payload := Payload{
Repo: "zoftko/felf-cli",
}
response, _ := pushPayload("token", server.URL+path, &payload)
if response.StatusCode != 302 {
t.Errorf("expected http %d, got %d", 302, response.StatusCode)
}
}