package store import ( "git.andreafazzi.eu/andrea/probo/models" "github.com/remogatto/prettytest" ) type collectionTestSuite struct { prettytest.Suite } func (t *collectionTestSuite) TestCreateCollection() { quizStore := NewQuizStore() quiz_1, _ := quizStore.Create( &models.Quiz{ Question: &models.Question{Text: "Question text #tag1 #tag3."}, Answers: []*models.Answer{ {Text: "Answer 1"}, {Text: "Answer 2"}, {Text: "Answer 3"}, {Text: "Answer 4"}, }, }) quizStore.Create( &models.Quiz{ Question: &models.Question{Text: "Question text #tag2."}, Answers: []*models.Answer{ {Text: "Answer 1"}, {Text: "Answer 2"}, {Text: "Answer 3"}, {Text: "Answer 4"}, }, }) quiz_2, _ := quizStore.Create( &models.Quiz{ Question: &models.Question{Text: "Question text #tag3."}, Answers: []*models.Answer{ {Text: "Answer 1"}, {Text: "Answer 2"}, {Text: "Answer 3"}, {Text: "Answer 4"}, }, }) collectionStore := NewStore[*models.Collection]() collection, err := collectionStore.Create( &models.Collection{ Name: "My Collection", }) t.Nil(err, "Collection should be created without error") if !t.Failed() { quizzes := quizStore.FilterInCollection(collection, &models.Filter{ Tags: []*models.Tag{ {Name: "#tag1"}, {Name: "#tag3"}, }, }) t.Equal(1, len(quizzes)) count := 0 for _, q := range collection.Quizzes { if quiz_1.ID == q.ID || quiz_2.ID == q.ID { count++ } } t.Equal(1, count) t.Equal(1, len(collection.Quizzes)) } }