github.com/qri-io/qri@v0.10.1-0.20220104210721-c771715036cb/repo/test/spec/test.go (about) 1 // Package spec contains a set of tests to ensure a repo implementation conforms 2 // to expected behaviors, calling RunRepoTests on a given repo implementation should 3 // pass all checks in order to properly work with Qri. 4 // test also has a TestRepo, which uses an in-memory implementation of Repo 5 // suited for tests that require a repo 6 package spec 7 8 import ( 9 "testing" 10 11 "github.com/qri-io/qri/repo" 12 ) 13 14 // RepoMakerFunc produces a new instance of a repository when called 15 // the returned cleanup function will be called at the end of each test, 16 // and can be used to do things like remove temp files 17 type RepoMakerFunc func(t *testing.T) (r repo.Repo, cleanup func()) 18 19 // repoTestFunc is a function for testing a repo 20 type repoTestFunc func(t *testing.T, rm RepoMakerFunc) 21 22 // RunRepoTests tests that this repo conforms to expected behaviors 23 func RunRepoTests(t *testing.T, rmf RepoMakerFunc) { 24 tests := map[string]repoTestFunc{ 25 "testRefstoreInvalidRefs": testRefstoreInvalidRefs, 26 "testRefstoreRefs": testRefstoreRefs, 27 "testRefstore": testRefstoreMain, 28 "testProfileStore": testProfileStore, 29 } 30 31 for key, test := range tests { 32 t.Run(key, func(t *testing.T) { 33 test(t, rmf) 34 }) 35 } 36 }