<commit_before>package transport

import (
	"net/http"
	"testing"

	"github.com/stretchr/testify/require"

	"github.com/algolia/algoliasearch-client-go/algolia/compression"
)

func TestShouldCompress(t *testing.T) {
	for _, c := range []struct {
		compression compression.Compression
		method      string
		expected    bool
	}{
		{0, "", false},
		{compression.None, "", false},
		{compression.None, http.MethodPost, false},
		{compression.None, http.MethodPut, false},
		{compression.None, http.MethodDelete, false},
		{compression.None, http.MethodGet, false},
		{compression.GZIP, http.MethodPost, true},
		{compression.GZIP, http.MethodPut, true},
		{compression.GZIP, http.MethodDelete, false},
		{compression.GZIP, http.MethodGet, false},
	} {
		got := shouldCompress(c.compression, c.method)
		require.Equal(t, c.expected, got, "compression=%d method=%q", c.compression, c.method)
	}
}<commit_msg>test: add more cases to transport.shouldCompress test<commit_after>package transport

import (
	"net/http"
	"testing"

	"github.com/stretchr/testify/require"

	"github.com/algolia/algoliasearch-client-go/algolia/compression"
)

func TestShouldCompress(t *testing.T) {
	fakeBody := map[string]interface{}{}
	for _, c := range []struct {
		compression compression.Compression
		method      string
		body        interface{}
		expected    bool
	}{
		{0, "", nil, false},
		{compression.None, "", nil, false},
		{compression.None, http.MethodPost, fakeBody, false},
		{compression.None, http.MethodPut, fakeBody, false},
		{compression.None, http.MethodDelete, fakeBody, false},
		{compression.None, http.MethodGet, fakeBody, false},
		{compression.GZIP, http.MethodPost, fakeBody, true},
		{compression.GZIP, http.MethodPut, fakeBody, true},
		{compression.GZIP, http.MethodDelete, fakeBody, false},
		{compression.GZIP, http.MethodGet, fakeBody, false},
		{compression.GZIP, http.MethodPost, nil, false},
		{compression.GZIP, http.MethodPut, nil, false},
	} {
		got := shouldCompress(c.compression, c.method, c.body)
		require.Equal(t, c.expected, got, "compression=%d method=%q", c.compression, c.method)
	}
}
{'fraction_non_alphanumeric': 0.14969208905731882, 'fraction_numerical': 0.0009474182851729038, 'mean_word_length': 4.754768392370572, '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': '2537246', 'n_tokens_mistral': 775, 'n_tokens_neox': 738, 'n_words': 145}