github.com/qri-io/qri@v0.10.1-0.20220104210721-c771715036cb/automation/workflow/workflow_test.go (about) 1 package workflow 2 3 import ( 4 "errors" 5 "testing" 6 "time" 7 8 "github.com/qri-io/qri/profile" 9 ) 10 11 func TestWorkflowValidate(t *testing.T) { 12 now := time.Now() 13 ownerID := profile.ID("profile_id") 14 cases := []struct { 15 description string 16 workflow *Workflow 17 expected error 18 }{ 19 {"nil workflow", nil, ErrNilWorkflow}, 20 {"no id", &Workflow{}, ErrNoWorkflowID}, 21 {"no dataset id", &Workflow{ID: "test_id"}, ErrNoInitID}, 22 {"no owner id", &Workflow{ID: "test_id", InitID: "dataset_id"}, ErrNoOwnerID}, 23 {"no created time", &Workflow{ID: "test_id", InitID: "dataset_id", OwnerID: ownerID}, ErrNilCreated}, 24 {"no error", &Workflow{ID: "test_id", InitID: "dataset_id", OwnerID: ownerID, Created: &now}, nil}, 25 } 26 for _, c := range cases { 27 got := c.workflow.Validate() 28 if !errors.Is(c.expected, got) { 29 t.Errorf("validate workflow case %q: expected %q, got %q", c.description, c.expected, got) 30 } 31 } 32 }