1package event23import "testing"45func TestJobKindClassification(t *testing.T) {6 tests := []struct {7 kind int8 request, answer, cancel, terminal, result bool9 }{10 {kind: 5000},11 {kind: KIND_SITE_SNAPSHOT},12 {kind: 7000},13 {kind: 43000},14 {kind: KIND_JOB_REQUEST, request: true},15 {kind: KIND_JOB_ACCEPTED, answer: true},16 {kind: KIND_JOB_PROGRESS, answer: true},17 {kind: KIND_JOB_RESULT, answer: true, terminal: true, result: true},18 {kind: KIND_JOB_CANCEL, cancel: true, terminal: true},19 {kind: KIND_JOB_ERROR, answer: true, terminal: true},20 {kind: 43007},21 }22 for _, tt := range tests {23 job := tt.request || tt.answer || tt.cancel24 if IsJobRequest(tt.kind) != tt.request || IsJobAnswer(tt.kind) != tt.answer || IsJobCancel(tt.kind) != tt.cancel || IsJobTerminal(tt.kind) != tt.terminal || IsJobResult(tt.kind) != tt.result || IsJobKind(tt.kind) != job {25 t.Errorf("kind %d: request=%v answer=%v cancel=%v terminal=%v result=%v job=%v", tt.kind, IsJobRequest(tt.kind), IsJobAnswer(tt.kind), IsJobCancel(tt.kind), IsJobTerminal(tt.kind), IsJobResult(tt.kind), IsJobKind(tt.kind))26 }27 }28}