Skip to content

Commit

Permalink
Add tests for question creation
Browse files Browse the repository at this point in the history
  • Loading branch information
SaadAhmedGit committed Dec 23, 2023
1 parent d96de4f commit 1e3bc0c
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/questions_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package tests

import (
"testing"

"github.com/stretchr/testify/assert"

"github.com/SaadAhmedGit/formify/internal/models"
)

func TestQuestionsCreation(t *testing.T) {
questions := []models.Question{
{
Type: "number",
Data: `{"label": "What is your name?"}`,
FormID: dummyForm.ID,
},
{
Type: "number",
Data: `{"label": "What is your age?"}`,
FormID: dummyForm.ID,
},
}

err := models.CreateQuestions(db, questions)
assert.NoError(t, err)
}

func createQuestionsTable() {
db.MustExec(models.CREATE_QUESTIONS_TABLE_QUERY)
}

func deleteQuestionsTable() {
db.MustExec(`DROP TABLE questions`)
}

0 comments on commit 1e3bc0c

Please sign in to comment.