-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeatures_additional_test.go
More file actions
44 lines (35 loc) · 1.05 KB
/
Copy pathfeatures_additional_test.go
File metadata and controls
44 lines (35 loc) · 1.05 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
package cloudflared
import (
"context"
"hash/fnv"
"testing"
)
func TestResolveRemoteDatagramVersionRejectsInvalidJSON(t *testing.T) {
t.Parallel()
_, err := resolveRemoteDatagramVersion("account", []byte("{"))
if err == nil {
t.Fatal("expected invalid JSON error")
}
}
func TestAccountEnabledThresholdBoundary(t *testing.T) {
t.Parallel()
hasher := fnv.New32a()
_, _ = hasher.Write([]byte("boundary-account"))
threshold := hasher.Sum32() % 100
if accountEnabled("boundary-account", threshold) {
t.Fatal("expected threshold percentage to remain disabled")
}
if !accountEnabled("boundary-account", threshold+1) {
t.Fatal("expected threshold+1 percentage to enable account")
}
}
func TestFeatureSelectorSnapshotReturnsIndependentFeatureSlice(t *testing.T) {
t.Parallel()
selector := newFeatureSelector(context.Background(), "account", defaultDatagramVersion)
_, first := selector.Snapshot()
first[0] = "mutated"
_, second := selector.Snapshot()
if second[0] == "mutated" {
t.Fatal("expected snapshot to return a copy of default features")
}
}