Don't run test if in CI

This commit is contained in:
2024-01-21 21:18:33 +01:00
parent 8f93f33a39
commit e4a9b8a790

View File

@ -1,18 +1,23 @@
package main
import (
"os"
"testing"
)
// Returns a string with a length between 1 and 2000 characters
func TestGetPostsFromReddit_ReturnsPostWithValidLength(t *testing.T) {
subreddit := "celebs"
post, err := GetPostsFromReddit(subreddit)
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
if len(post) < 1 || len(post) > 2000 {
t.Errorf("Post length is not within the valid range")
if os.Getenv("CI") == "" {
subreddit := "celebs"
post, err := GetPostsFromReddit(subreddit)
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
if len(post) < 1 || len(post) > 2000 {
t.Errorf("Post length is not within the valid range")
}
} else {
t.Skip("Skipping test in CI environment as the IP is probably blocked by Reddit")
}
}