mirror of
https://github.com/outbackdingo/matchbox.git
synced 2026-03-20 15:43:13 +00:00
* Remove api.Store and use storagepb.Store instead * Remove api.Spec and use storagepb.Profile instead * Switch from api.Group to storagepb.Group * Move api.Group to config for YAML config decoding only
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package api
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/coreos/coreos-baremetal/bootcfg/storage/storagepb"
|
|
"github.com/stretchr/testify/assert"
|
|
"golang.org/x/net/context"
|
|
)
|
|
|
|
func TestContextProfile(t *testing.T) {
|
|
expectedProfile := &storagepb.Profile{Id: "g1h2i3j4"}
|
|
ctx := withProfile(context.Background(), expectedProfile)
|
|
profile, err := profileFromContext(ctx)
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, expectedProfile, profile)
|
|
}
|
|
|
|
func TestContextProfile_Error(t *testing.T) {
|
|
profile, err := profileFromContext(context.Background())
|
|
assert.Nil(t, profile)
|
|
if assert.NotNil(t, err) {
|
|
assert.Equal(t, errNoProfileFromContext, err)
|
|
}
|
|
}
|
|
|
|
func TestContextGroup(t *testing.T) {
|
|
expectedGroup := &storagepb.Group{Name: "test group"}
|
|
ctx := withGroup(context.Background(), expectedGroup)
|
|
group, err := groupFromContext(ctx)
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, expectedGroup, group)
|
|
}
|
|
|
|
func TestContextGroup_Error(t *testing.T) {
|
|
group, err := groupFromContext(context.Background())
|
|
assert.Nil(t, group)
|
|
if assert.NotNil(t, err) {
|
|
assert.Equal(t, errNoGroupFromContext, err)
|
|
}
|
|
}
|