cloudflare/cloudflared

Public

mirrored from https://github.com/cloudflare/cloudflaredAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
2021.1.2

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

edgediscovery/protocol_test.go

80lines · modecode

1package edgediscovery
2
3import (
4 "testing"
5
6 "github.com/stretchr/testify/assert"
7)
8
9func TestHTTP2Percentage(t *testing.T) {
10 _, err := HTTP2Percentage()
11 assert.NoError(t, err)
12}
13
14func TestParseHTTP2Precentage(t *testing.T) {
15 tests := []struct {
16 record string
17 percentage int32
18 wantErr bool
19 }{
20 {
21 record: "http2=-1",
22 percentage: -1,
23 wantErr: false,
24 },
25 {
26 record: "http2=0",
27 percentage: 0,
28 wantErr: false,
29 },
30 {
31 record: "http2=50",
32 percentage: 50,
33 wantErr: false,
34 },
35 {
36 record: "http2=100",
37 percentage: 100,
38 wantErr: false,
39 },
40 {
41 record: "http2=1000",
42 percentage: 1000,
43 wantErr: false,
44 },
45 {
46 record: "http2=10.5",
47 wantErr: true,
48 },
49 {
50 record: "http2=10 h2mux=90",
51 wantErr: true,
52 },
53 {
54 record: "http2=ten",
55 wantErr: true,
56 },
57
58 {
59 record: "h2mux=100",
60 wantErr: true,
61 },
62 {
63 record: "http2",
64 wantErr: true,
65 },
66 {
67 record: "http2=",
68 wantErr: true,
69 },
70 }
71
72 for _, test := range tests {
73 p, err := parseHTTP2Precentage(test.record)
74 if test.wantErr {
75 assert.Error(t, err)
76 } else {
77 assert.Equal(t, test.percentage, p)
78 }
79 }
80}
81