github.com/alimy/mir/v4@v4.1.0/internal/internal_test.go (about) 1 // Copyright 2020 Michael Li <alimy@gility.net>. All rights reserved. 2 // Use of this source code is governed by Apache License 2.0 that 3 // can be found in the LICENSE file. 4 5 package internal 6 7 import ( 8 "errors" 9 "testing" 10 ) 11 12 func TestMirCtx(t *testing.T) { 13 ctx := NewMirCtx(10) 14 if ctx.Capcity() != 10 { 15 t.Error("want capcity is 10 but not") 16 } 17 ctx.Cancel(errors.New("just an error")) 18 ctx.Cancel(errors.New("another error")) 19 if err := ctx.Err(); err != nil && err.Error() != "just an error" { 20 t.Error("want 'just an error' but not") 21 } 22 }