github.com/sacloud/libsacloud/v2@v2.32.3/helper/service/bridge/service_test.go (about) 1 // Copyright 2016-2022 The Libsacloud Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package bridge 16 17 import ( 18 "testing" 19 20 "github.com/sacloud/libsacloud/v2/sacloud" 21 "github.com/sacloud/libsacloud/v2/sacloud/pointer" 22 23 "github.com/sacloud/libsacloud/v2/sacloud/testutil" 24 ) 25 26 func TestBridgeService_CRUD(t *testing.T) { 27 svc := New(testutil.SingletonAPICaller()) 28 name := testutil.ResourceName("bridge") 29 testZone := testutil.TestZone() 30 31 testutil.RunCRUD(t, &testutil.CRUDTestCase{ 32 Parallel: true, 33 IgnoreStartupWait: true, 34 SetupAPICallerFunc: testutil.SingletonAPICaller, 35 Create: &testutil.CRUDTestFunc{ 36 Func: func(ctx *testutil.CRUDTestContext, _ sacloud.APICaller) (interface{}, error) { 37 return svc.Create(&CreateRequest{ 38 Zone: testZone, 39 Name: name, 40 Description: "desc", 41 }) 42 }, 43 }, 44 Read: &testutil.CRUDTestFunc{ 45 Func: func(ctx *testutil.CRUDTestContext, _ sacloud.APICaller) (interface{}, error) { 46 return svc.Read(&ReadRequest{ID: ctx.ID, Zone: testZone}) 47 }, 48 }, 49 Updates: []*testutil.CRUDTestFunc{ 50 { 51 Func: func(ctx *testutil.CRUDTestContext, _ sacloud.APICaller) (interface{}, error) { 52 return svc.Update(&UpdateRequest{ 53 ID: ctx.ID, 54 Name: pointer.NewString(name + "-upd"), 55 Description: pointer.NewString("test-upd"), 56 Zone: testZone, 57 }) 58 }, 59 }, 60 }, 61 Delete: &testutil.CRUDTestDeleteFunc{ 62 Func: func(ctx *testutil.CRUDTestContext, _ sacloud.APICaller) error { 63 return svc.Delete(&DeleteRequest{ID: ctx.ID, Zone: testZone}) 64 }, 65 }, 66 }) 67 }