Skip to content

Commit

Permalink
Merged Pull Request '#29 feat/if-modified-test->main : feat: cover if…
Browse files Browse the repository at this point in the history
…-modified-since case'

feat: cover if-modified-since case
  • Loading branch information
Automation51D authored Apr 25, 2024
2 parents 6ffa53b + 40d783f commit 02f7175
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions onpremise/file_pulling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,39 @@ func TestTooManyRetries(t *testing.T) {
if !errors.Is(err, ErrTooManyRetries) {
t.Fatalf("Expected error to be ErrTooManyRetries, got %v", err)
}
}

func newMockServerModifiedSince() *httptest.Server {
return httptest.NewServer(
http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {

val := r.Header.Get("If-Modified-Since")
if val == "" {
w.WriteHeader(http.StatusBadRequest)
return
}

w.WriteHeader(http.StatusNotModified)
},
),
)
}

func TestIfModifiedSince(t *testing.T) {
server := newMockServerModifiedSince()

defer server.Close()

timeStamp := time.Now()
_, err := doDataFileRequest(
server.URL, logWrapper{
enabled: true,
logger: DefaultLogger,
}, &timeStamp,
)

if !errors.Is(err, ErrFileNotModified) {
t.Errorf("Expected error to be ErrFileNotModified, got %v", err)
}
}

0 comments on commit 02f7175

Please sign in to comment.