github.com/matrixorigin/matrixone@v1.2.0/pkg/backup/types_test.go (about)

     1  // Copyright 2023 Matrix Origin
     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 backup
    16  
    17  import (
    18  	"github.com/stretchr/testify/assert"
    19  	"testing"
    20  )
    21  
    22  func TestMetas_AppendLaunchconfig(t *testing.T) {
    23  	type fields struct {
    24  		metas []*Meta
    25  	}
    26  	type args struct {
    27  		subTyp string
    28  		file   string
    29  		check  func(t *testing.T, m *Metas)
    30  	}
    31  	tests := []struct {
    32  		name   string
    33  		fields fields
    34  		args   args
    35  	}{
    36  		{
    37  			name:   "t1",
    38  			fields: fields{},
    39  			args: args{
    40  				subTyp: "sub",
    41  				file:   "t1",
    42  				check: func(t *testing.T, m *Metas) {
    43  					assert.Equal(t, 0, len(m.metas))
    44  				},
    45  			},
    46  		},
    47  		{
    48  			name:   "t2",
    49  			fields: fields{},
    50  			args: args{
    51  				subTyp: CnConfig,
    52  				file:   "t2",
    53  				check: func(t *testing.T, m *Metas) {
    54  					assert.Equal(t, 1, len(m.metas))
    55  					assert.Equal(t, CnConfig, m.metas[0].SubTyp)
    56  					assert.Equal(t, "t2", m.metas[0].LaunchConfigFile)
    57  				},
    58  			},
    59  		},
    60  	}
    61  	for _, tt := range tests {
    62  		t.Run(tt.name, func(t *testing.T) {
    63  			m := &Metas{
    64  				metas: tt.fields.metas,
    65  			}
    66  			m.AppendLaunchconfig(tt.args.subTyp, tt.args.file)
    67  			tt.args.check(t, m)
    68  		})
    69  	}
    70  }