| 1 | package kongscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/ |
| 2 | |
| 3 | import ( |
| 4 | "testingscip-go gomod github.com/golang/go/src go1.12 testing/" |
| 5 | |
| 6 | uuidscip-go gomod github.com/satori/go.uuid v1.2.0 `github.com/satori/go.uuid`/ "github.com/satori/go.uuidscip-go gomod github.com/satori/go.uuid v1.2.0 `github.com/satori/go.uuid`/" |
| 7 | "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/" |
| 8 | ) |
| 9 | |
| 10 | func TestUpstreamsServicescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/TestUpstreamsService().(T *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 11 | assert := assertscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/.Newscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/New().(T) |
| 12 | |
| 13 | client, err := NewTestClientscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/NewTestClient().(nil, nil) |
| 14 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 15 | assert.NotNilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#NotNil().(client) |
| 16 | |
| 17 | upstream := &Upstreamscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#{ |
| 18 | Namescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#Name.: Stringscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/String().("virtual-host1"), |
| 19 | } |
| 20 | |
| 21 | createdUpstream, err := client.Upstreamsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Client#Upstreams..Createscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/UpstreamService#Create().(defaultCtxscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/defaultCtx., upstream) |
| 22 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 23 | assert.NotNilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#NotNil().(createdUpstream) |
| 24 | |
| 25 | upstream, err = client.Upstreamsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Client#Upstreams..Getscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/UpstreamService#Get().(defaultCtxscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/defaultCtx., createdUpstream.IDscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#ID.) |
| 26 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 27 | assert.NotNilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#NotNil().(upstream) |
| 28 | |
| 29 | upstream.Namescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#Name. = Stringscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/String().("virtual-host2") |
| 30 | upstream, err = client.Upstreamsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Client#Upstreams..Updatescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/UpstreamService#Update().(defaultCtxscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/defaultCtx., upstream) |
| 31 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 32 | assert.NotNilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#NotNil().(upstream) |
| 33 | assert.Equalscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Equal().("virtual-host2", *upstream.Namescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#Name.) |
| 34 | |
| 35 | err = client.Upstreamsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Client#Upstreams..Deletescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/UpstreamService#Delete().(defaultCtxscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/defaultCtx., createdUpstream.IDscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#ID.) |
| 36 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 37 | |
| 38 | // ID can be specified |
| 39 | id := uuidscip-go gomod github.com/satori/go.uuid v1.2.0 `github.com/satori/go.uuid`/.NewV4scip-go gomod github.com/satori/go.uuid v1.2.0 `github.com/satori/go.uuid`/NewV4().().Stringscip-go gomod github.com/satori/go.uuid v1.2.0 `github.com/satori/go.uuid`/UUID#String().() |
| 40 | upstream = &Upstreamscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#{ |
| 41 | Namescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#Name.: Stringscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/String().("key-auth"), |
| 42 | IDscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#ID.: Stringscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/String().(id), |
| 43 | } |
| 44 | |
| 45 | createdUpstream, err = client.Upstreamsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Client#Upstreams..Createscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/UpstreamService#Create().(defaultCtxscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/defaultCtx., upstream) |
| 46 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 47 | assert.NotNilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#NotNil().(createdUpstream) |
| 48 | assert.Equalscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(id, *createdUpstream.IDscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#ID.) |
| 49 | |
| 50 | err = client.Upstreamsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Client#Upstreams..Deletescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/UpstreamService#Delete().(defaultCtxscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/defaultCtx., createdUpstream.IDscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#ID.) |
| 51 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 52 | } |
| 53 | |
| 54 | func TestUpstreamWithTagsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/TestUpstreamWithTags().(T *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 55 | runWhenKongscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/runWhenKong().(T, ">=1.1.0") |
| 56 | assert := assertscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/.Newscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/New().(T) |
| 57 | |
| 58 | client, err := NewTestClientscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/NewTestClient().(nil, nil) |
| 59 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 60 | assert.NotNilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#NotNil().(client) |
| 61 | |
| 62 | upstream := &Upstreamscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#{ |
| 63 | Namescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#Name.: Stringscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/String().("key-auth"), |
| 64 | Tagsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#Tags.: StringSlicescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/StringSlice().("tag1", "tag2"), |
| 65 | } |
| 66 | |
| 67 | createdUpstream, err := client.Upstreamsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Client#Upstreams..Createscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/UpstreamService#Create().(defaultCtxscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/defaultCtx., upstream) |
| 68 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 69 | assert.NotNilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#NotNil().(createdUpstream) |
| 70 | assert.Equalscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(StringSlicescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/StringSlice().("tag1", "tag2"), createdUpstream.Tagsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#Tags.) |
| 71 | |
| 72 | err = client.Upstreamsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Client#Upstreams..Deletescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/UpstreamService#Delete().(defaultCtxscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/defaultCtx., createdUpstream.IDscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#ID.) |
| 73 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 74 | } |
| 75 | |
| 76 | // regression test for #6 |
| 77 | func TestUpstreamWithActiveUnHealthyIntervalscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/TestUpstreamWithActiveUnHealthyInterval().(T *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 78 | assert := assertscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/.Newscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/New().(T) |
| 79 | |
| 80 | client, err := NewTestClientscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/NewTestClient().(nil, nil) |
| 81 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 82 | assert.NotNilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#NotNil().(client) |
| 83 | |
| 84 | upstream := &Upstreamscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#{ |
| 85 | Namescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#Name.: Stringscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/String().("upstream-foo"), |
| 86 | Healthchecksscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#Healthchecks.: &Healthcheckscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Healthcheck#{ |
| 87 | Activescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Healthcheck#Active.: &ActiveHealthcheckscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/ActiveHealthcheck#{ |
| 88 | Unhealthyscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/ActiveHealthcheck#Unhealthy.: &Unhealthyscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Unhealthy#{ |
| 89 | Intervalscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Unhealthy#Interval.: Intscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Int().(5), |
| 90 | }, |
| 91 | }, |
| 92 | }, |
| 93 | } |
| 94 | |
| 95 | createdUpstream, err := client.Upstreamsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Client#Upstreams..Createscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/UpstreamService#Create().(defaultCtxscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/defaultCtx., upstream) |
| 96 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 97 | assert.NotNilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#NotNil().(createdUpstream) |
| 98 | |
| 99 | err = client.Upstreamsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Client#Upstreams..Deletescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/UpstreamService#Delete().(defaultCtxscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/defaultCtx., createdUpstream.IDscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#ID.) |
| 100 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 101 | } |
| 102 | |
| 103 | // regression test for #6 |
| 104 | func TestUpstreamWithPassiveUnHealthyIntervalscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/TestUpstreamWithPassiveUnHealthyInterval().(T *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 105 | assert := assertscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/.Newscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/New().(T) |
| 106 | |
| 107 | client, err := NewTestClientscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/NewTestClient().(nil, nil) |
| 108 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 109 | assert.NotNilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#NotNil().(client) |
| 110 | |
| 111 | upstream := &Upstreamscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#{ |
| 112 | Namescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#Name.: Stringscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/String().("upstream-foo"), |
| 113 | Healthchecksscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#Healthchecks.: &Healthcheckscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Healthcheck#{ |
| 114 | Passivescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Healthcheck#Passive.: &PassiveHealthcheckscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/PassiveHealthcheck#{ |
| 115 | Unhealthyscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/PassiveHealthcheck#Unhealthy.: &Unhealthyscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Unhealthy#{ |
| 116 | Intervalscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Unhealthy#Interval.: Intscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Int().(5), |
| 117 | }, |
| 118 | }, |
| 119 | }, |
| 120 | } |
| 121 | |
| 122 | createdUpstream, err := client.Upstreamsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Client#Upstreams..Createscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/UpstreamService#Create().(defaultCtxscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/defaultCtx., upstream) |
| 123 | assert.NotNilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#NotNil().(err) |
| 124 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(createdUpstream) |
| 125 | } |
| 126 | func TestUpstreamWithPassiveHealthyscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/TestUpstreamWithPassiveHealthy().(T *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 127 | assert := assertscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/.Newscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/New().(T) |
| 128 | |
| 129 | client, err := NewTestClientscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/NewTestClient().(nil, nil) |
| 130 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 131 | assert.NotNilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#NotNil().(client) |
| 132 | |
| 133 | upstream := &Upstreamscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#{ |
| 134 | Namescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#Name.: Stringscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/String().("upstream-foo"), |
| 135 | Healthchecksscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#Healthchecks.: &Healthcheckscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Healthcheck#{ |
| 136 | Passivescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Healthcheck#Passive.: &PassiveHealthcheckscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/PassiveHealthcheck#{ |
| 137 | Typescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/PassiveHealthcheck#Type.: Stringscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/String().("http"), |
| 138 | Healthyscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/PassiveHealthcheck#Healthy.: &Healthyscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Healthy#{ |
| 139 | HTTPStatusesscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Healthy#HTTPStatuses.: []int{200, 201}, |
| 140 | Successesscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Healthy#Successes.: Intscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Int().(3), |
| 141 | }, |
| 142 | }, |
| 143 | }, |
| 144 | } |
| 145 | |
| 146 | createdUpstream, err := client.Upstreamsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Client#Upstreams..Createscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/UpstreamService#Create().(defaultCtxscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/defaultCtx., upstream) |
| 147 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 148 | assert.NotNilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#NotNil().(createdUpstream) |
| 149 | assert.Equalscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Equal().("http", *createdUpstream.Healthchecksscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#Healthchecks..Passivescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Healthcheck#Passive..Typescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/PassiveHealthcheck#Type.) |
| 150 | |
| 151 | err = client.Upstreamsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Client#Upstreams..Deletescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/UpstreamService#Delete().(defaultCtxscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/defaultCtx., createdUpstream.IDscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#ID.) |
| 152 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 153 | } |
| 154 | |
| 155 | func TestUpstreamWithAlgorithmscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/TestUpstreamWithAlgorithm().(T *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 156 | runWhenKongscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/runWhenKong().(T, ">=1.3.0") |
| 157 | assert := assertscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/.Newscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/New().(T) |
| 158 | |
| 159 | client, err := NewTestClientscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/NewTestClient().(nil, nil) |
| 160 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 161 | assert.NotNilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#NotNil().(client) |
| 162 | |
| 163 | upstream := &Upstreamscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#{ |
| 164 | Namescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#Name.: Stringscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/String().("upstream1"), |
| 165 | Algorithmscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#Algorithm.: Stringscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/String().("least-connections"), |
| 166 | } |
| 167 | |
| 168 | createdUpstream, err := client.Upstreamsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Client#Upstreams..Createscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/UpstreamService#Create().(defaultCtxscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/defaultCtx., upstream) |
| 169 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 170 | assert.NotNilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#NotNil().(createdUpstream) |
| 171 | assert.Equalscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Equal().("least-connections", *createdUpstream.Algorithmscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#Algorithm.) |
| 172 | |
| 173 | err = client.Upstreamsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Client#Upstreams..Deletescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/UpstreamService#Delete().(defaultCtxscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/defaultCtx., createdUpstream.IDscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#ID.) |
| 174 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 175 | } |
| 176 | |
| 177 | func TestUpstreamListEndpointscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/TestUpstreamListEndpoint().(T *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 178 | assert := assertscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/.Newscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/New().(T) |
| 179 | |
| 180 | client, err := NewTestClientscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/NewTestClient().(nil, nil) |
| 181 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 182 | assert.NotNilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#NotNil().(client) |
| 183 | |
| 184 | // fixtures |
| 185 | upstreams := []*Upstreamscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#{ |
| 186 | { |
| 187 | Namescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#Name.: Stringscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/String().("vhost1.com"), |
| 188 | }, |
| 189 | { |
| 190 | Namescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#Name.: Stringscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/String().("vhost2.com"), |
| 191 | }, |
| 192 | { |
| 193 | Namescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#Name.: Stringscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/String().("vhost3.com"), |
| 194 | }, |
| 195 | } |
| 196 | |
| 197 | // create fixturs |
| 198 | for i := 0; i < len(upstreams); i++ { |
| 199 | upstream, err := client.Upstreamsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Client#Upstreams..Createscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/UpstreamService#Create().(defaultCtxscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/defaultCtx., upstreams[i]) |
| 200 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 201 | assert.NotNilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#NotNil().(upstream) |
| 202 | upstreams[i] = upstream |
| 203 | } |
| 204 | |
| 205 | upstreamsFromKong, next, err := client.Upstreamsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Client#Upstreams..Listscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/UpstreamService#List().(defaultCtxscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/defaultCtx., nil) |
| 206 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 207 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(next) |
| 208 | assert.NotNilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#NotNil().(upstreamsFromKong) |
| 209 | assert.Equalscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(3, len(upstreamsFromKong)) |
| 210 | |
| 211 | // check if we see all upstreams |
| 212 | assert.Truescip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#True().(compareUpstreamsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/compareUpstreams().(upstreams, upstreamsFromKong)) |
| 213 | |
| 214 | // Test pagination |
| 215 | upstreamsFromKong = []*Upstreamscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#{} |
| 216 | |
| 217 | // first page |
| 218 | page1, next, err := client.Upstreamsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Client#Upstreams..Listscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/UpstreamService#List().(defaultCtxscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/defaultCtx., &ListOptscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/ListOpt#{Sizescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/ListOpt#Size.: 1}) |
| 219 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 220 | assert.NotNilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#NotNil().(next) |
| 221 | assert.NotNilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#NotNil().(page1) |
| 222 | assert.Equalscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(1, len(page1)) |
| 223 | upstreamsFromKong = append(upstreamsFromKong, page1...) |
| 224 | |
| 225 | // second page |
| 226 | page2, next, err := client.Upstreamsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Client#Upstreams..Listscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/UpstreamService#List().(defaultCtxscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/defaultCtx., next) |
| 227 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 228 | assert.NotNilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#NotNil().(next) |
| 229 | assert.NotNilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#NotNil().(page2) |
| 230 | assert.Equalscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(1, len(page2)) |
| 231 | upstreamsFromKong = append(upstreamsFromKong, page2...) |
| 232 | |
| 233 | // last page |
| 234 | page3, next, err := client.Upstreamsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Client#Upstreams..Listscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/UpstreamService#List().(defaultCtxscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/defaultCtx., next) |
| 235 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 236 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(next) |
| 237 | assert.NotNilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#NotNil().(page3) |
| 238 | assert.Equalscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(1, len(page3)) |
| 239 | upstreamsFromKong = append(upstreamsFromKong, page3...) |
| 240 | |
| 241 | assert.Truescip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#True().(compareUpstreamsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/compareUpstreams().(upstreams, upstreamsFromKong)) |
| 242 | |
| 243 | upstreams, err = client.Upstreamsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Client#Upstreams..ListAllscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/UpstreamService#ListAll().(defaultCtxscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/defaultCtx.) |
| 244 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 245 | assert.NotNilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#NotNil().(upstreams) |
| 246 | assert.Equalscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(3, len(upstreams)) |
| 247 | |
| 248 | for i := 0; i < len(upstreams); i++ { |
| 249 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(client.Upstreamsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Client#Upstreams..Deletescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/UpstreamService#Delete().(defaultCtxscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/defaultCtx., upstreams[i].IDscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#ID.)) |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | func compareUpstreamsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/compareUpstreams().(expected, actual []*Upstreamscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#) bool { |
| 254 | var expectedNames, actualNames []string |
| 255 | for _, upstream := range expected { |
| 256 | expectedNames = append(expectedNames, *upstream.Namescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#Name.) |
| 257 | } |
| 258 | |
| 259 | for _, upstream := range actual { |
| 260 | actualNames = append(actualNames, *upstream.Namescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#Name.) |
| 261 | } |
| 262 | |
| 263 | return (compareSlicesscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/compareSlices().(expectedNames, actualNames)) |
| 264 | } |
| 265 | |
| 266 | func TestUpstreamsWithHostHeaderscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/TestUpstreamsWithHostHeader().(T *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 267 | runWhenKongscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/runWhenKong().(T, ">=1.4.0") |
| 268 | assert := assertscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/.Newscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/New().(T) |
| 269 | |
| 270 | client, err := NewTestClientscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/NewTestClient().(nil, nil) |
| 271 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 272 | assert.NotNilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#NotNil().(client) |
| 273 | |
| 274 | upstream := &Upstreamscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#{ |
| 275 | Namescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#Name.: Stringscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/String().("upstream-with-host-header"), |
| 276 | HostHeaderscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#HostHeader.: Stringscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/String().("example.com"), |
| 277 | } |
| 278 | |
| 279 | createdUpstream, err := client.Upstreamsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Client#Upstreams..Createscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/UpstreamService#Create().(defaultCtxscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/defaultCtx., upstream) |
| 280 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 281 | assert.NotNilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#NotNil().(createdUpstream) |
| 282 | assert.Equalscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Equal().("example.com", *createdUpstream.HostHeaderscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#HostHeader.) |
| 283 | |
| 284 | err = client.Upstreamsscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Client#Upstreams..Deletescip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/UpstreamService#Delete().(defaultCtxscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/defaultCtx., createdUpstream.IDscip-go gomod github.com/kong/go-kong . `github.com/kong/go-kong/kong`/Upstream#ID.) |
| 285 | assert.Nilscip-go gomod github.com/stretchr/testify v1.4.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err) |
| 286 | } |