Skip to content

Commit

Permalink
fix(ci): lint & tests pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
darkweak committed Nov 30, 2023
1 parent 6f6bc30 commit 1734fab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 85 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ jobs:

steps:
- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Print Go version and environment
id: vars
Expand Down Expand Up @@ -72,9 +72,9 @@ jobs:

steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: '1.19'
go-version: '1.21'
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
Expand Down
81 changes: 0 additions & 81 deletions httpcache_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package httpcache

import (
"fmt"
"net/http"
"os"
"path"
"strings"
"sync"
"testing"
"time"

Expand Down Expand Up @@ -293,83 +289,6 @@ func TestNotHandledRoute(t *testing.T) {
}
}

func TestMultiProvider(t *testing.T) {
var wg sync.WaitGroup
var responses []*http.Response

for i := 0; i < 3; i++ {
wg.Add(1)

go func(tt *testing.T) {
tester := caddytest.NewTester(t)
tester.InitServer(`
{
admin localhost:2999
http_port 9080
https_port 9443
cache {
nuts {
path ./souin-nuts
}
ttl 1000s
storers badger nuts
}
}
localhost:9080 {
route /multi-storage {
cache
respond "Hello, multi-storage!"
}
}`, "caddyfile")

resp, _ := tester.AssertGetResponse("http://localhost:9080/multi-storage", 200, "Hello, multi-storage!")
responses = append(responses, resp)
resp, _ = tester.AssertGetResponse("http://localhost:9080/multi-storage", 200, "Hello, multi-storage!")
responses = append(responses, resp)
wg.Done()
}(t)

wg.Wait()
time.Sleep(time.Second)
}

resp1 := responses[0]
if resp1.Header.Get("Cache-Status") != "Souin; fwd=uri-miss; stored; key=GET-http-localhost:9080-/multi-storage" {
t.Errorf("unexpected resp1 Cache-Status header %v", resp1.Header.Get("Cache-Status"))
}
if resp1.Header.Get("Age") != "" {
t.Errorf("unexpected resp1 Age header %v", resp1.Header.Get("Age"))
}
resp1 = responses[1]
if resp1.Header.Get("Cache-Status") != "Souin; hit; ttl=999; key=GET-http-localhost:9080-/multi-storage" {
t.Errorf("unexpected resp3 Cache-Status header %v", resp1.Header.Get("Cache-Status"))
}
if resp1.Header.Get("Age") != "1" {
t.Errorf("unexpected resp1 Age header %v", resp1.Header.Get("Age"))
}

for i := 0; i < (len(responses)/2)-1; i++ {
currentIteration := 2 + (i * 2)
resp := responses[currentIteration]
if resp.Header.Get("Cache-Status") != "Souin; hit; ttl="+fmt.Sprint(998-i)+"; key=GET-http-localhost:9080-/multi-storage" {
t.Errorf("unexpected resp%d Cache-Status header %v", currentIteration, resp.Header.Get("Cache-Status"))
}
if resp.Header.Get("Age") != fmt.Sprint(2+i) {
t.Errorf("unexpected resp%d Age header %v", currentIteration, resp.Header.Get("Age"))
}
currentIteration++
resp = responses[currentIteration]
if resp.Header.Get("Cache-Status") != "Souin; hit; ttl="+fmt.Sprint(998-i)+"; key=GET-http-localhost:9080-/multi-storage" {
t.Errorf("unexpected resp%d Cache-Status header %v", currentIteration, resp.Header.Get("Cache-Status"))
}
if resp.Header.Get("Age") != fmt.Sprint(2+i) {
t.Errorf("unexpected resp%d Age header %v", currentIteration, resp.Header.Get("Age"))
}
}

os.RemoveAll(path.Join(".", "souin-nuts"))
}

func TestAuthenticatedRoute(t *testing.T) {
tester := caddytest.NewTester(t)
tester.InitServer(`
Expand Down

0 comments on commit 1734fab

Please sign in to comment.