add config load test
This commit is contained in:
		
							parent
							
								
									ed4ee637ab
								
							
						
					
					
						commit
						6b1f3fc256
					
				
							
								
								
									
										38
									
								
								pkg/config/config_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								pkg/config/config_test.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,38 @@
 | 
			
		||||
package config
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"os"
 | 
			
		||||
	"path"
 | 
			
		||||
	"testing"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestLoad(t *testing.T) {
 | 
			
		||||
	type args struct {
 | 
			
		||||
		p []string
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	wd, err := os.Getwd()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Errorf("Get WD error = %v", err)
 | 
			
		||||
	}
 | 
			
		||||
	fp := path.Join(wd, "..", "..", "config", "config.yml")
 | 
			
		||||
 | 
			
		||||
	tests := []struct {
 | 
			
		||||
		name    string
 | 
			
		||||
		args    args
 | 
			
		||||
		wantErr bool
 | 
			
		||||
	}{
 | 
			
		||||
		{
 | 
			
		||||
			name:    "test load config",
 | 
			
		||||
			args:    args{p: []string{fp}},
 | 
			
		||||
			wantErr: false,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	for _, tt := range tests {
 | 
			
		||||
		t.Run(tt.name, func(t *testing.T) {
 | 
			
		||||
			if err := Load(tt.args.p...); (err != nil) != tt.wantErr {
 | 
			
		||||
				t.Errorf("Load() error = %v, wantErr %v", err, tt.wantErr)
 | 
			
		||||
			}
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user