mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-10-31 20:14:21 +00:00
21 lines
358 B
Go
21 lines
358 B
Go
package api
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"testing"
|
|
)
|
|
|
|
func TestContext(t *testing.T) {
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
cancel() // lol
|
|
|
|
client := NewClient("no. 3-chan").WithContext(ctx)
|
|
|
|
// This should fail.
|
|
_, err := client.Me()
|
|
if err == nil || !errors.Is(err, context.Canceled) {
|
|
t.Fatal("Unexpected error:", err)
|
|
}
|
|
}
|