forked from growthbook/growthbook-golang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeature_api_response_test.go
115 lines (112 loc) · 2.29 KB
/
feature_api_response_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
package growthbook
import (
"encoding/json"
"testing"
)
const jsonData = `{
"status": 200,
"features": {
"banner_text": {
"defaultValue": "Welcome to Acme Donuts!",
"rules": [
{
"condition": {
"country": "france"
},
"force": "Bienvenue au Beignets Acme !"
},
{
"condition": {
"country": "spain"
},
"force": "¡Bienvenidos y bienvenidas a Donas Acme!"
}
]
},
"dark_mode": {
"defaultValue": false,
"rules": [
{
"condition": {
"loggedIn": true
},
"force": true,
"coverage": 0.5,
"hashAttribute": "id"
}
]
},
"donut_price": {
"defaultValue": 2.5,
"rules": [
{
"condition": {
"employee": true
},
"force": 0
}
]
},
"meal_overrides_gluten_free": {
"defaultValue": {
"meal_type": "standard",
"dessert": "Strawberry Cheesecake"
},
"rules": [
{
"condition": {
"dietaryRestrictions": {
"$elemMatch": {
"$eq": "gluten_free"
}
}
},
"force": {
"meal_type": "gf",
"dessert": "French Vanilla Ice Cream"
}
}
]
},
"app_name": {
"defaultValue": "(unknown)",
"rules": [
{
"condition": {
"version": {
"$vgte": "1.0.0",
"$vlt": "2.0.0"
}
},
"force": "Albatross"
},
{
"condition": {
"version": {
"$vgte": "2.0.0",
"$vlt": "3.0.0"
}
},
"force": "Badger"
},
{
"condition": {
"version": {
"$vgte": "3.0.0",
"$vlt": "4.0.0"
}
},
"force": "Capybara"
}
]
}
},
"dateUpdated": "2023-06-27T18:10:13.378Z"
}`
func TestAPIResponseParsing(t *testing.T) {
apiResponse := FeatureAPIResponse{}
err := json.Unmarshal([]byte(jsonData), &apiResponse)
if err != nil {
t.Errorf("failed to parse API response data")
}
}