package workflow import ( "testing" "github.com/samcharles93/archie-core/internal/config" "github.com/samcharles93/archie-core/internal/domain/workflow/task" ) func TestInstructionsLayerBroadestFirst(t *testing.T) { tests := []struct { name string tc TaskContext rules string want string }{ {name: "none leaves the rules", tc: TaskContext{runInterfaceSet: true}, rules: "R", want: "R"}, { name: "every layer in order, then the rules", tc: TaskContext{ Instructions: Instructions{Instance: "I", Organisation: "O"}, Repo: config.Repo{Instructions: "P"}, runInterface: task.WorkflowInterface{Instructions: "W"}, runInterfaceSet: true, }, rules: "R", want: "## Instructions\n\n### Instance\n\nI\n\n### Organisation\n\nO\n\n### Workflow\n\nW\n\n### Repository\n\nP\n\nR", }, { name: "blank layers are skipped", tc: TaskContext{Instructions: Instructions{Organisation: " "}, Repo: config.Repo{Instructions: "P"}, runInterfaceSet: true}, want: "## Instructions\n\n### Repository\n\nP\n", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := tt.tc.withInstructions(tt.rules); got != tt.want { t.Errorf("got %q, want %q", got, tt.want) } }) } }