Skip to content

Commit

Permalink
Increase test coverage for standards
Browse files Browse the repository at this point in the history
  • Loading branch information
James C. Scott committed Aug 19, 2016
1 parent 7f1c5cc commit 0e1d033
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions lib/standards_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package lib

import (
"testing"
"github.com/opencontrol/compliance-masonry/lib/common/mocks"
"github.com/stretchr/testify/assert"
"github.com/opencontrol/compliance-masonry/lib/common"
)

func TestGetStandard(t *testing.T) {
// Setup map
m := newStandards()
// Get nil component.
standard := m.Get("test")
assert.Nil(t, standard)
// Create mock component
newStandard := new(mocks.Standard)
newStandard.On("GetName").Return("test")
// Test add method
m.Add(newStandard)
// Try to retrieve the component again.
standard = m.Get("test")
assert.Equal(t, standard.GetName(), "test")
}

func TestBadLoadStandard(t *testing.T) {
// Setup map
m := newStandards()
ws := LocalWorkspace{Standards: m}
err := ws.LoadStandard("fake.file")
assert.NotNil(t, err)
assert.Equal(t, common.ErrStandardSchema, err)
}

0 comments on commit 0e1d033

Please sign in to comment.