<commit_before>package gothumbor

import (
	"strings"
	"testing"
)

const IMAGEURL = "my.server.com/some/path/to/image.jpg"
const WIDTH = 300
const HEIGHT = 200
const ENCRYPTEDURL = "8ammJH8D-7tXy6kU3lTvoXlhu4o=/300x200/my.server.com/some/path/to/image.jpg"
const UNSAFEURL = "/300x200/my.server.com/some/path/to/image.jpg"

func TestGetUrlPartialWithWidthAndHeight(t *testing.T) {
	thumborOptions := ThumborOptions{Width: 1, Height: 1, Smart: false}
	url, err := getURLParts(IMAGEURL, thumborOptions)
	if err != nil {
		t.Error("Got an error when tried to generate the thumbor url", err)
	}

	urlE := strings.Join([]string{"1x1", IMAGEURL}, "/")
	if url != urlE {
		t.Errorf("Got an unxpected partial url: %s != %s", url, urlE)
	}
}

func TestGetUrlPartialWithSmart(t *testing.T) {
	thumborOptions := ThumborOptions{Width: 1, Height: 1, Smart: true}
	url, err := getURLParts(IMAGEURL, thumborOptions)
	if err != nil {
		t.Error("Got an error when tried to generate the thumbor url", err)
	}

	urlE := strings.Join([]string{"1x1", "smart", IMAGEURL}, "/")
	if url != urlE {
		t.Errorf("Got an unxpected partial url: %s != %s", url, urlE)
	}
}

func TestGetUrlPartialOnlyWithWidthAndHeight(t *testing.T) {
	thumborOptions := ThumborOptions{Width: WIDTH, Height: HEIGHT}
	url, err := getURLParts(IMAGEURL, thumborOptions)
	if err != nil {
		t.Error("Got an error when tried to generate the thumbor url", err)
	}
	if url != strings.Join([]string{"300x200", IMAGEURL}, "/") {
		t.Error("Got an unxpected partial path:", url)
	}
}

func TestFitInParameter(t *testing.T) {
	thumborOptions := ThumborOptions{FitIn: true}

	url, err := getURLParts(IMAGEURL, thumborOptions)
	if err == nil || url == "" {
		t.Errorf("Got an error when tried to generate the thumbor url")
	}

	if !strings.Contains(url, "fit-in") {
		t.Errorf("url doesn't have a fit-in parameter")
	}

}
<commit_msg>Fixing testing parameters to fit-in test.<commit_after>package gothumbor

import (
	"strings"
	"testing"
)

const IMAGEURL = "my.server.com/some/path/to/image.jpg"
const WIDTH = 300
const HEIGHT = 200
const ENCRYPTEDURL = "8ammJH8D-7tXy6kU3lTvoXlhu4o=/300x200/my.server.com/some/path/to/image.jpg"
const UNSAFEURL = "/300x200/my.server.com/some/path/to/image.jpg"

func TestGetUrlPartialWithWidthAndHeight(t *testing.T) {
	thumborOptions := ThumborOptions{Width: 1, Height: 1, Smart: false}
	url, err := getURLParts(IMAGEURL, thumborOptions)
	if err != nil {
		t.Error("Got an error when tried to generate the thumbor url", err)
	}

	urlE := strings.Join([]string{"1x1", IMAGEURL}, "/")
	if url != urlE {
		t.Errorf("Got an unxpected partial url: %s != %s", url, urlE)
	}
}

func TestGetUrlPartialWithSmart(t *testing.T) {
	thumborOptions := ThumborOptions{Width: 1, Height: 1, Smart: true}
	url, err := getURLParts(IMAGEURL, thumborOptions)
	if err != nil {
		t.Error("Got an error when tried to generate the thumbor url", err)
	}

	urlE := strings.Join([]string{"1x1", "smart", IMAGEURL}, "/")
	if url != urlE {
		t.Errorf("Got an unxpected partial url: %s != %s", url, urlE)
	}
}

func TestGetUrlPartialOnlyWithWidthAndHeight(t *testing.T) {
	thumborOptions := ThumborOptions{Width: WIDTH, Height: HEIGHT}
	url, err := getURLParts(IMAGEURL, thumborOptions)
	if err != nil {
		t.Error("Got an error when tried to generate the thumbor url", err)
	}
	if url != strings.Join([]string{"300x200", IMAGEURL}, "/") {
		t.Error("Got an unxpected partial path:", url)
	}
}

func TestFitInParameter(t *testing.T) {
	thumborOptions := ThumborOptions{FitIn: true}

	url, err := getURLParts(IMAGEURL, thumborOptions)
	if err != nil || url == "" {
		t.Errorf("Got an error when tried to generate the thumbor url")
	}

	if !strings.Contains(url, "fit-in") {
		t.Errorf("url doesn't have a fit-in parameter")
	}

}

{'fraction_non_alphanumeric': 0.1483836777954425, 'fraction_numerical': 0.020137784843667197, 'mean_word_length': 4.584319526627219, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '167669', 'n_tokens_mistral': 1493, 'n_tokens_neox': 1416, 'n_words': 357}