mirror of
https://github.com/outbackdingo/matchbox.git
synced 2026-01-27 18:19:36 +00:00
25 lines
538 B
Go
25 lines
538 B
Go
package api
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"golang.org/x/net/context"
|
|
)
|
|
|
|
func TestContextSpec(t *testing.T) {
|
|
expectedSpec := &Spec{ID: "g1h2i3j4"}
|
|
ctx := withSpec(context.Background(), expectedSpec)
|
|
spec, err := specFromContext(ctx)
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, expectedSpec, spec)
|
|
}
|
|
|
|
func TestContextSpec_Error(t *testing.T) {
|
|
spec, err := specFromContext(context.Background())
|
|
assert.Nil(t, spec)
|
|
if assert.NotNil(t, err) {
|
|
assert.Equal(t, "api: Context missing a Spec", err.Error())
|
|
}
|
|
}
|