github.com/alibaba/sealer@v0.8.6-0.20220430115802-37a2bdaa8173/pkg/plugin/labels_test.go (about) 1 // Copyright © 2021 Alibaba Group Holding Ltd. 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 plugin 16 17 import ( 18 "testing" 19 20 v1 "github.com/alibaba/sealer/types/api/v1" 21 ) 22 23 func TestLabelsNodes_Run(t *testing.T) { 24 type fields struct { 25 data map[string][]label 26 } 27 28 plugin := &v1.Plugin{} 29 plugin.Spec.Data = "192.9.200.21 ws=demo21\n192.9.200.22 ssd=true\n192.9.200.23 ssd=true,hdd=false" 30 31 type args struct { 32 context Context 33 phase Phase 34 } 35 tests := []struct { 36 name string 37 fields fields 38 args args 39 wantErr bool 40 }{ 41 // TODO: Add test cases. 42 { 43 "test label to cluster node", 44 fields{}, 45 args{ 46 context: Context{ 47 Plugin: plugin, 48 }, 49 phase: PhasePostInstall, 50 }, 51 false, 52 }, 53 } 54 for _, tt := range tests { 55 t.Run(tt.name, func(t *testing.T) { 56 l := LabelsNodes{ 57 data: tt.fields.data, 58 } 59 if err := l.Run(tt.args.context, tt.args.phase); (err != nil) != tt.wantErr { 60 t.Errorf("LabelsNodes.Run() error = %v, wantErr %v", err, tt.wantErr) 61 } 62 }) 63 } 64 }