Before we conclude our tour of the in-memory graph implementation, we need to spend some time authoring a test suite that will execute the shared verification suite against the store implementation we just created. This can be achieved with only a handful of lines, as follows:
var _ = gc.Suite(new(InMemoryGraphTestSuite)) type InMemoryGraphTestSuite struct { graphtest.SuiteBase } func (s *InMemoryGraphTestSuite) SetUpTest(c *gc.C) { s.SetGraph(NewInMemoryGraph()) } // Register our test-suite with go test. func Test(t *testing.T) { gc.TestingT(t) }
Since we are working with a pure, in-memory implementation, we can cheat and recreate the graph before running each test by providing a SetUpTest method that the gocheck framework will automatically invoke for us when running the test suite.