-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
50 lines (41 loc) · 1.2 KB
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"log/slog"
"os"
"testing"
"github.com/mmcdole/gofeed"
)
func TestSquareRatio(t *testing.T) {
orientation := determineRatio("test_images/square.jpg")
if orientation != "square" {
t.Fatalf(`determineRatio("test_images/square.jpg") = %q, want "square"`, orientation)
}
}
func TestWideRatio(t *testing.T) {
orientation := determineRatio("test_images/wide.jpg")
if orientation != "wide" {
t.Fatalf(`determineRatio("test_images/wide.jpg") = %q, want "wide"`, orientation)
}
}
func TestTallRatio(t *testing.T) {
orientation := determineRatio("test_images/tall.jpg")
if orientation != "tall" {
t.Fatalf(`determineRatio("test_images/tall.jpg") = %q, want "tall"`, orientation)
}
}
func TestGetImageMeta(t *testing.T) {
file, _ := os.Open("test.xml")
defer file.Close()
fp := gofeed.NewParser()
feed, _ := fp.Parse(file)
fakeLogger1 := slog.Default()
fakeLogger2 := slog.Default()
logs := [2]*slog.Logger{fakeLogger1, fakeLogger2}
images := getImageMeta(*feed, logs)
if len(images) != 3 {
t.Fatalf(`len(images) = %q, want 3`, len(images))
}
if images[0].Title != "The First Space Shuttle" {
t.Fatalf(`images[0][0] == %q, want "The First Space Shuttle"`, images[0].Title)
}
}