jokes-bapak2/api/core/submit/setter_test.go

26 lines
568 B
Go
Raw Normal View History

package submit_test
import (
"context"
"jokes-bapak2-api/core/schema"
"jokes-bapak2-api/core/submit"
"testing"
2021-11-08 12:39:29 +00:00
"time"
)
func TestSubmitJoke(t *testing.T) {
2021-11-08 12:39:29 +00:00
ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(30*time.Second))
defer cancel()
2021-11-08 15:55:07 +00:00
defer Flush()
2021-11-08 12:39:29 +00:00
s, err := submit.SubmitJoke(db, ctx, schema.Submission{Author: "Test <example@test.com>"}, "https://example.net/img.png")
if err != nil {
t.Error("an error was thrown:", err)
}
if s.Link != "https://example.net/img.png" {
t.Error("link is not correct, got:", s.Link)
}
}