github.com/kubevela/workflow@v0.6.0/pkg/backup/sls/producer_test.go (about) 1 package sls 2 3 import ( 4 "context" 5 "testing" 6 7 monitorContext "github.com/kubevela/pkg/monitor/context" 8 "github.com/stretchr/testify/require" 9 10 "github.com/kubevela/workflow/api/v1alpha1" 11 ) 12 13 func TestHandler_Store(t *testing.T) { 14 tests := []struct { 15 name string 16 config map[string][]byte 17 run *v1alpha1.WorkflowRun 18 wantErr bool 19 }{ 20 { 21 name: "Success", 22 config: map[string][]byte{ 23 "AccessKeyID": []byte("accessKeyID"), 24 "AccessKeySecret": []byte("accessKeySecret"), 25 "Endpoint": []byte("endpoint"), 26 "ProjectName": []byte("project"), 27 "LogStoreName": []byte("logstore"), 28 }, 29 wantErr: false, 30 }, 31 } 32 for _, tt := range tests { 33 t.Run(tt.name, func(t *testing.T) { 34 r := require.New(t) 35 ctx := monitorContext.NewTraceContext(context.Background(), "test") 36 s, err := NewSLSHandler(tt.config) 37 r.NoError(err) 38 if err := s.Store(ctx, tt.run); (err != nil) != tt.wantErr { 39 t.Errorf("Store() error = %v, wantErr %v", err, tt.wantErr) 40 } 41 }) 42 } 43 }