-
Notifications
You must be signed in to change notification settings - Fork 0
/
blueprint_internal_test.go
122 lines (110 loc) · 2.45 KB
/
blueprint_internal_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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2023-Present Datadog, Inc.
package cloudcraft
import (
"net/url"
"reflect"
"strconv"
"testing"
)
func TestImageExportParams_query(t *testing.T) {
t.Parallel()
tests := []struct {
name string
give ImageExportParams
want url.Values
}{
{
name: "Empty parameters",
want: url.Values{},
},
{
name: "All parameters set",
give: ImageExportParams{
PaperSize: "A4",
Grid: true,
Transparent: true,
Landscape: true,
Scale: 1.5,
Width: 1024,
Height: 768,
},
want: url.Values{
"paperSize": []string{"A4"},
"grid": []string{"true"},
"transparent": []string{"true"},
"landscape": []string{"true"},
"scale": []string{strconv.FormatFloat(1.5, 'f', -1, 32)},
"width": []string{"1024"},
"height": []string{"768"},
},
},
{
name: "Only paperSize and transparent",
give: ImageExportParams{
PaperSize: "A3",
Transparent: true,
},
want: url.Values{
"paperSize": []string{"A3"},
"transparent": []string{"true"},
},
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
if got := tt.give.query(); !reflect.DeepEqual(got, tt.want) {
t.Fatalf("ImageExportParams.query() = %v, want %v", got, tt.want)
}
})
}
}
func TestBudgetExportParams_query(t *testing.T) {
t.Parallel()
tests := []struct {
name string
give BudgetExportParams
want url.Values
}{
{
name: "Empty parameters",
want: url.Values{},
},
{
name: "All parameters set",
give: BudgetExportParams{
Currency: "USD",
Period: "monthly",
Rate: "standard",
},
want: url.Values{
"currency": []string{"USD"},
"period": []string{"monthly"},
"rate": []string{"standard"},
},
},
{
name: "Only currency and period",
give: BudgetExportParams{
Currency: "EUR",
Period: "yearly",
},
want: url.Values{
"currency": []string{"EUR"},
"period": []string{"yearly"},
},
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
if got := tt.give.query(); !reflect.DeepEqual(got, tt.want) {
t.Fatalf("BudgetExportParams.query() = %v, want %v", got, tt.want)
}
})
}
}