Upstream sync
This commit is contained in:
50
controllers/text_templates_controller_test.go
Normal file
50
controllers/text_templates_controller_test.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package controllers_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gitlab.com/pactual1/backend/shared"
|
||||
)
|
||||
|
||||
func TestListTextTemplates(t *testing.T) {
|
||||
ts := runTestServer()
|
||||
defer ts.Close()
|
||||
defer shared.CloseDb()
|
||||
|
||||
t.Run("it should return 200", func(t *testing.T) {
|
||||
resp, err := http.Get(fmt.Sprintf("%s/text_templates?limit=20", ts.URL))
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("Expected no error, got %v", err)
|
||||
}
|
||||
|
||||
assert.Equal(t, 200, resp.StatusCode)
|
||||
})
|
||||
}
|
||||
|
||||
func CreateTextTemplate(t *testing.T) {
|
||||
ts := runTestServer()
|
||||
defer ts.Close()
|
||||
defer shared.CloseDb()
|
||||
|
||||
t.Run("it should return 200", func(t *testing.T) {
|
||||
// Add a new text template
|
||||
data := map[string]interface{}{
|
||||
"Value": "text",
|
||||
}
|
||||
|
||||
payload, _ := json.Marshal(data)
|
||||
resp, err := http.Post(fmt.Sprintf("%s/text_templates/save", ts.URL), "application/json", bytes.NewBuffer(payload))
|
||||
if err != nil {
|
||||
t.Fatalf("Expected no error, got %v", err)
|
||||
}
|
||||
|
||||
assert.Equal(t, 200, resp.StatusCode)
|
||||
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user