github.com/alibaba/sealer@v0.8.6-0.20220430115802-37a2bdaa8173/pkg/config/pre_process_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 config 16 17 import ( 18 "testing" 19 20 v1 "github.com/alibaba/sealer/types/api/v1" 21 ) 22 23 func TestNewProcessorsAndRun(t *testing.T) { 24 config := &v1.Config{ 25 Spec: v1.ConfigSpec{ 26 Process: "value|toJson|toBase64|toSecret", 27 Data: ` 28 config: 29 usrname: root 30 passwd: xxx 31 `, 32 }, 33 } 34 35 type args struct { 36 config *v1.Config 37 } 38 tests := []struct { 39 name string 40 args args 41 wantErr bool 42 }{ 43 { 44 name: "test value|toJson|toBase64|toSecret", 45 args: args{config}, 46 wantErr: false, 47 }, 48 } 49 for _, tt := range tests { 50 t.Run(tt.name, func(t *testing.T) { 51 if err := NewProcessorsAndRun(tt.args.config); (err != nil) != tt.wantErr || tt.args.config.Spec.Data != "config: eyJwYXNzd2QiOiJ4eHgiLCJ1c3JuYW1lIjoicm9vdCJ9\n" { 52 t.Errorf("NewProcessorsAndRun() error = %v, wantErr %v", err, tt.wantErr) 53 } 54 }) 55 } 56 }