-
Notifications
You must be signed in to change notification settings - Fork 2
/
printer_one_line_test.go
98 lines (68 loc) · 4.58 KB
/
printer_one_line_test.go
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package main
import (
"bytes"
"strings"
"testing"
)
func TestShowEndpointsOneLine(t *testing.T) {
conf, _ := NewConfiguration(NewSilentConfigurationReader("_resources/valid", "api-requests.yaml"))
var b bytes.Buffer
printer := &Printer{conf: conf, writer: &b, oneLine: true}
printer.ShowEndpoints()
if allEndpointsOutputOneLine != strings.Trim(b.String(), " \n\t") {
t.Error("All endpoints output doesn't look correct")
}
}
func TestShowRequestsOneLine(t *testing.T) {
conf, _ := NewConfiguration(NewSilentConfigurationReader("_resources/valid", "api-requests.yaml"))
var b bytes.Buffer
printer := &Printer{conf: conf, writer: &b, oneLine: true}
printer.ShowRequests()
if allRequestsOutputOneLine != strings.Trim(b.String(), " \n\t") {
t.Error("All requests output doesn't look correct")
}
}
func TestShowEndpointOneLine(t *testing.T) {
conf, _ := NewConfiguration(NewSilentConfigurationReader("_resources/valid", "api-requests.yaml"))
var b bytes.Buffer
printer := &Printer{conf: conf, writer: &b, oneLine: true}
printer.ShowRequestOrEndpoint("endpoint1")
if endpoint1OutputOneLine != strings.Trim(b.String(), " \n\t") {
t.Error("endpoint1 output doesn't look correct")
}
}
func TestShowRequestOneLine(t *testing.T) {
conf, _ := NewConfiguration(NewSilentConfigurationReader("_resources/valid", "api-requests.yaml"))
var b bytes.Buffer
printer := &Printer{conf: conf, writer: &b, oneLine: true}
printer.ShowRequestOrEndpoint("request1")
if request1OutputOneLine != strings.Trim(b.String(), " \n\t") {
t.Error("endpoint1 output doesn't look correct")
}
}
var endpoint1OutputOneLine = `Endpoint endpoint1:
curl 'https://localhost/path1' -H 'Accept: application/vnd.github.v3+json' -H 'Authorization: bearer a12b3c' -H 'Custom: value' -G --data-urlencode 'version=v2' --data-urlencode 'format=json' --data-urlencode 'spec=20' --compress --silent -s -vvv -XGET`
var request1OutputOneLine = `Endpoint request1:
curl 'https://localhost/path1' -H 'Accept: application/vnd.github.v3+json' -H 'Authorization: bearer a12b3c' -H 'Custom: value' -G --data-urlencode 'version=v2' --data-urlencode 'format=json' --data-urlencode 'spec=20' --compress --silent -s -vvv -XGET`
var allEndpointsOutputOneLine = `Endpoint endpoint1:
curl 'https://localhost/path1' -H 'Accept: application/vnd.github.v3+json' -H 'Authorization: bearer a12b3c' -H 'Custom: value' -G --data-urlencode 'version=v2' --data-urlencode 'format=json' --data-urlencode 'spec=20' --compress --silent -s -vvv -XGET
Endpoint endpoint2:
curl 'https://localhost/path2/{variable}/something' -H 'Accept: application/vnd.github.v3+json' -H 'Authorization: bearer a12b3c' -H 'Custom: value' --compress --silent -s -vvv -XGET
Endpoint endpoint3:
curl 'https://localhost/path3' -H 'Accept: application/vnd.github.v3+json' -H 'Authorization: bearer a12b3c' -H 'Content-length: 0' -H 'Custom: value' --compress --silent -s -vvv -XPUT
Endpoint endpoint4:
curl 'https://localhost/path4/{variable}?name={name}&date={date}&version={version}' -H 'Accept: application/vnd.github.v3+json' -H 'Authorization: bearer a12b3c' -H 'Custom: value' --compress --silent -s -vvv -XPOST
Endpoint endpoint5:
curl 'https://localhost/' -H 'Accept: application/vnd.github.v3+json' -H 'Authorization: bearer a12b3c' -H 'Custom: value' --compress --silent -s -vvv -XDELETE`
var allRequestsOutputOneLine = `Endpoint request1:
curl 'https://localhost/path1' -H 'Accept: application/vnd.github.v3+json' -H 'Authorization: bearer a12b3c' -H 'Custom: value' -G --data-urlencode 'version=v2' --data-urlencode 'format=json' --data-urlencode 'spec=20' --compress --silent -s -vvv -XGET
Endpoint request2:
curl 'https://localhost/path2/value/something' -H 'Accept: application/vnd.github.v3+json' -H 'Authorization: bearer a12b3c' -H 'Custom: value' --compress --silent -s -vvv -XGET
Endpoint request3:
curl 'https://localhost/path3' -H 'Accept: application/vnd.github.v3+json' -H 'Authorization: bearer a12b3c' -H 'Content-length: 0' -H 'Custom: value' --compress --silent -s -vvv -XPUT
Endpoint request4:
curl 'https://localhost/path4/value?name=gohit&date=today&version=15' -H 'Accept: application/vnd.github.v3+json' -H 'Authorization: bearer a12b3c' -H 'Custom: value' --compress --silent -s -vvv -XPOST
Endpoint request4_1:
curl 'https://localhost/path4/value?name=gohit1&date=today1&version=16' -H 'Accept: application/vnd.github.v3+json' -H 'Authorization: bearer a12b3c' -H 'Custom: value' --compress --silent -s -vvv -XPOST
Endpoint request5:
curl 'https://localhost/' -H 'Accept: application/vnd.github.v3+json' -H 'Authorization: bearer a12b3c' -H 'Custom: value' --compress --silent -s -vvv -XDELETE`