2021-11-08 09:58:41 +00:00
|
|
|
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"
|
2021-11-08 09:58:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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
|
|
|
|
2021-11-08 09:58:41 +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")
|
2021-11-08 09:58:41 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|