github.com/polarismesh/polaris@v1.17.8/service/circuitbreaker_config_test.go (about) 1 /** 2 * Tencent is pleased to support the open source community by making Polaris available. 3 * 4 * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 * 6 * Licensed under the BSD 3-Clause License (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * https://opensource.org/licenses/BSD-3-Clause 11 * 12 * Unless required by applicable law or agreed to in writing, software distributed 13 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 * specific language governing permissions and limitations under the License. 16 */ 17 18 package service_test 19 20 import ( 21 "testing" 22 23 "github.com/polarismesh/specification/source/go/api/v1/fault_tolerance" 24 apimodel "github.com/polarismesh/specification/source/go/api/v1/model" 25 "github.com/polarismesh/specification/source/go/api/v1/service_manage" 26 "github.com/stretchr/testify/assert" 27 ) 28 29 func TestServer_CircuitBreakersConfig(t *testing.T) { 30 discoverSuit := &DiscoverTestSuit{} 31 if err := discoverSuit.Initialize(); err != nil { 32 t.Fatal(err) 33 } 34 defer discoverSuit.Destroy() 35 36 resp := discoverSuit.DiscoverServer().CreateCircuitBreakers(discoverSuit.DefaultCtx, 37 []*fault_tolerance.CircuitBreaker{}) 38 assert.Equal(t, apimodel.Code_BadRequest, apimodel.Code(resp.GetCode().GetValue())) 39 40 resp = discoverSuit.DiscoverServer().CreateCircuitBreakerVersions(discoverSuit.DefaultCtx, 41 []*fault_tolerance.CircuitBreaker{}) 42 assert.Equal(t, apimodel.Code_BadRequest, apimodel.Code(resp.GetCode().GetValue())) 43 44 resp = discoverSuit.DiscoverServer().DeleteCircuitBreakers(discoverSuit.DefaultCtx, 45 []*fault_tolerance.CircuitBreaker{}) 46 assert.Equal(t, apimodel.Code_BadRequest, apimodel.Code(resp.GetCode().GetValue())) 47 48 resp = discoverSuit.DiscoverServer().UpdateCircuitBreakers(discoverSuit.DefaultCtx, 49 []*fault_tolerance.CircuitBreaker{}) 50 assert.Equal(t, apimodel.Code_BadRequest, apimodel.Code(resp.GetCode().GetValue())) 51 52 resp = discoverSuit.DiscoverServer().ReleaseCircuitBreakers(discoverSuit.DefaultCtx, 53 []*service_manage.ConfigRelease{}) 54 assert.Equal(t, apimodel.Code_BadRequest, apimodel.Code(resp.GetCode().GetValue())) 55 56 resp = discoverSuit.DiscoverServer().UnBindCircuitBreakers(discoverSuit.DefaultCtx, 57 []*service_manage.ConfigRelease{}) 58 assert.Equal(t, apimodel.Code_BadRequest, apimodel.Code(resp.GetCode().GetValue())) 59 60 qresp := discoverSuit.DiscoverServer().GetCircuitBreaker(discoverSuit.DefaultCtx, 61 map[string]string{}) 62 assert.Equal(t, apimodel.Code_BadRequest, apimodel.Code(qresp.GetCode().GetValue())) 63 64 qresp = discoverSuit.DiscoverServer().GetCircuitBreakerVersions(discoverSuit.DefaultCtx, 65 map[string]string{}) 66 assert.Equal(t, apimodel.Code_BadRequest, apimodel.Code(resp.GetCode().GetValue())) 67 68 qresp = discoverSuit.DiscoverServer().GetMasterCircuitBreakers(discoverSuit.DefaultCtx, 69 map[string]string{}) 70 assert.Equal(t, apimodel.Code_BadRequest, apimodel.Code(resp.GetCode().GetValue())) 71 72 qresp = discoverSuit.DiscoverServer().GetReleaseCircuitBreakers(discoverSuit.DefaultCtx, 73 map[string]string{}) 74 assert.Equal(t, apimodel.Code_BadRequest, apimodel.Code(resp.GetCode().GetValue())) 75 76 qresp = discoverSuit.DiscoverServer().GetCircuitBreakerByService(discoverSuit.DefaultCtx, 77 map[string]string{}) 78 assert.Equal(t, apimodel.Code_BadRequest, apimodel.Code(resp.GetCode().GetValue())) 79 80 tresp := discoverSuit.DiscoverServer().GetCircuitBreakerToken(discoverSuit.DefaultCtx, 81 &fault_tolerance.CircuitBreaker{}) 82 assert.Equal(t, apimodel.Code_BadRequest, apimodel.Code(tresp.GetCode().GetValue())) 83 }