-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test the various ways of dispatching calls
- Loading branch information
Showing
6 changed files
with
187 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package dispatchtest | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/dispatchrun/dispatch-go" | ||
) | ||
|
||
func AssertCalls(t *testing.T, got, want []dispatch.Call) { | ||
t.Helper() | ||
|
||
if len(got) != len(want) { | ||
t.Fatalf("unexpected number of calls: got %v, want %v", len(got), len(want)) | ||
} | ||
for i, call := range got { | ||
if !call.Equal(want[i]) { | ||
t.Errorf("unexpected call %d: got %#v, want %#v", i, call, want[i]) | ||
} | ||
} | ||
} | ||
|
||
func AssertCall(t *testing.T, got, want dispatch.Call) { | ||
t.Helper() | ||
|
||
if !got.Equal(want) { | ||
t.Errorf("unexpected call: got %#v, want %#v", got, want) | ||
} | ||
} | ||
|
||
func AssertDispatchRequests(t *testing.T, got, want []DispatchRequest) { | ||
t.Helper() | ||
|
||
if len(got) != len(want) { | ||
t.Fatalf("unexpected number of requests: got %v, want %v", len(got), len(want)) | ||
} | ||
for i, req := range got { | ||
if req.ApiKey != want[i].ApiKey { | ||
t.Errorf("unexpected API key on request %d: got %v, want %v", i, req.ApiKey, want[i].ApiKey) | ||
} | ||
AssertCalls(t, req.Calls, want[i].Calls) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters