From bcfee77f6d064c92e54c93ac6f8d2a19a42597ba Mon Sep 17 00:00:00 2001 From: VnPower Date: Sat, 11 Nov 2023 17:34:36 +0700 Subject: [PATCH] Update test/CI files --- .woodpecker.yml | 2 +- pixivfe_test.go | 56 ++++++++++++++++++++++++++++++------------------- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index f24c697..e797a62 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -7,5 +7,5 @@ steps: - CGO_ENABLED=0 GOOS=linux go build -mod=readonly -o pixivfe - ./pixivfe & - sleep 3 - - go test -v + - go test -v -bench=. -count 5 secrets: [pixivfe_token] diff --git a/pixivfe_test.go b/pixivfe_test.go index 7167fb0..7c9e274 100644 --- a/pixivfe_test.go +++ b/pixivfe_test.go @@ -5,58 +5,72 @@ import ( "testing" ) -func Test_Main(t *testing.T) { - _, err := http.Get("http://localhost:8282/") +func Benchmark_Main(t *testing.B) { + r, err := http.Get("http://localhost:8282/") + if r.StatusCode != 200 { + t.Errorf("Status code not 200: was %d", r.StatusCode) + } if err != nil { t.Error(err) } - t.Logf("/ passed") } -func Test_Settings(t *testing.T) { - _, err := http.Get("http://localhost:8282/settings") +func Benchmark_Ranking(t *testing.B) { + r, err := http.Get("http://localhost:8282/ranking") + if r.StatusCode != 200 { + t.Errorf("Status code not 200: was %d", r.StatusCode) + } if err != nil { t.Error(err) } - t.Logf("Settings route passed") } -func Test_Ranking(t *testing.T) { - _, err := http.Get("http://localhost:8282/ranking") +func Benchmark_Ranking_Complex(t *testing.B) { + r, err := http.Get("http://localhost:8282/ranking?content=all&mode=daily_r18&page=1&date=20230826") + if r.StatusCode != 200 { + t.Errorf("Status code not 200: was %d", r.StatusCode) + } if err != nil { t.Error(err) } - t.Logf("Ranking route passed") } -func Test_Ranking_Complex(t *testing.T) { - _, err := http.Get("https://pixivfe.exozy.me/ranking?content=all&mode=daily_r18&page=1&date=20230826") +func Benchmark_Artwork(t *testing.B) { + r, err := http.Get("http://localhost:8282/artworks/111157207") + if r.StatusCode != 200 { + t.Errorf("Status code not 200: was %d", r.StatusCode) + } if err != nil { t.Error(err) } - t.Logf("Complex ranking route passed") } -func Test_Artwork(t *testing.T) { - _, err := http.Get("http://localhost:8282/artworks/111157207") +func Benchmark_Artwork_R18(t *testing.B) { + r, err := http.Get("http://localhost:8282/artworks/111130033") + if r.StatusCode != 200 { + t.Errorf("Status code not 200: was %d", r.StatusCode) + } if err != nil { t.Error(err) } - t.Logf("Artwork route passed") } -func Test_Artwork_R18(t *testing.T) { - _, err := http.Get("http://localhost:8282/artworks/111130033") +func Benchmark_User_NoSocial(t *testing.B) { + r, err := http.Get("http://localhost:8282/users/1035047") + if r.StatusCode != 200 { + t.Errorf("Status code not 200: was %d", r.StatusCode) + } if err != nil { t.Error(err) } - t.Logf("R18 Artwork route passed") } -func Test_User(t *testing.T) { - _, err := http.Get("http://localhost:8282/users/1960050") +func Benchmark_User_WithSocial(t *testing.B) { + r, err := http.Get("http://localhost:8282/users/59336265") + if r.StatusCode != 200 { + t.Errorf("Status code not 200: was %d", r.StatusCode) + } if err != nil { t.Error(err) } - t.Logf("User route passed") }