<commit_before>package air

import (
	"bytes"
	"compress/gzip"
	"context"
	"errors"
	"io"
	"io/ioutil"
	"log"
	"net/http"
	"net/http/httptest"
	"os"
	"path"
	"path/filepath"
	"sync"
	"testing"
	"time"

	"github.com/stretchr/testify/assert"
)

func TestNew(t *testing.T) {
	a := New()

	assert.Equal(t, "air", a.AppName)
	assert.Empty(t, a.MaintainerEmail)
	assert.False(t, a.DebugMode)
	assert.Equal(t, ":8080", a.Address)
	assert.Nil(t, a.HostWhitelist)
	assert.Zero(t, a.ReadTimeout)
	assert.Zero(t, a.ReadHeaderTimeout)
	assert.Zero(t, a.WriteTimeout)
	assert.Zero(t, a.IdleTimeout)
	assert.Equal(t, 1048576, a.MaxHeaderBytes)
	assert.Empty(t, a.TLSCertFile)
	assert.Empty(t, a.TLSKeyFile)
	assert.False(t, a.ACMEEnabled)
	assert.Equal(
		t,
		"https://acme-v01.api.letsencrypt.org/directory",
		a.ACMEDirectoryURL,
	)
	assert.Equal(t, "acme-certs", a.ACMECertRoot)
	assert.False(t, a.HTTPSEnforced)
	assert.Zero(t, a.WebSocketHandshakeTimeout)
	assert.Nil(t, a.WebSocketSubprotocols)
	assert.Nil(t, a.Pregases)
	assert.Nil(t, a.Gases)
	assert.IsType(t, DefaultNotFoundHandler, a.NotFoundHandler)
	assert.IsType(
		t,
		DefaultMethodNotAllowedHandler,
		a.MethodNotAllowedHandler,
	)
	assert.IsType(t, DefaultErrorHandler, a.ErrorHandler)
	assert.Nil(t, a.ErrorLogger)
	assert.False(t, a.AutoPushEnabled)
	assert.False(t, a.MinifierEnabled)
	assert.ElementsMatch(t, a.MinifierMIMETypes, []string{
		"text/html",
		"text/css",
		"application/javascript",
		"application/json",
		"application/xml",
		"image/svg+xml",
	})
	assert.False(t, a.GzipEnabled)
	assert.Equal(t, int64(1024), a.GzipMinContentLength)
	assert.ElementsMatch(t, a.GzipMIMETypes, []string{
		"text/plain",
		"text/html",
		"text/css",
		"application/javascript",
		"application/json",
		"application/xml",
		"application/toml",
		"application/yaml",
		"image/svg+xml",
	})
	assert.Equal(t, gzip.DefaultCompression, a.GzipCompressionLevel)
	assert.Equal(t, 8192, a.GzipFlushThreshold)
	assert.Equal(t, "templates", a.RendererTemplateRoot)
	assert.ElementsMatch(t, a.RendererTemplateExts, []string{".html"})
	assert.Equal(t, "{{", a.RendererTemplateLeftDelim)
	assert.Equal(t, "}}", a.RendererTemplateRightDelim)
	assert.Nil(t, a.RendererTemplateFuncMap)
	assert.False(t, a.CofferEnabled)
	assert.Equal(t, 33554432, a.CofferMaxMemoryBytes)
	assert.Equal(t, "assets", a.CofferAssetRoot)
	assert.ElementsMatch(t, a.CofferAssetExts, []string{
		".html",
		".css",
		".js",
		".json",
		".xml",
		".toml",
		".yaml",
		".yml",
		".svg",
		".jpg",
		".jpeg",
		".png",
		".gif",
	})
	assert.False(t, a.I18nEnabled)
	assert.Equal(t, "locales", a.I18nLocaleRoot)
	assert.Equal(t, "en-US", a.I18nLocaleBase)
	assert.Empty(t, a.ConfigFile)

	assert.NotNil(t, a.errorLogger)
	assert.IsType(t, &errorLogWriter{}, a.errorLogger.Writer())
	assert.Empty(t, a.errorLogger.Prefix())
	assert.Zero(t, a.errorLogger.Flags())

	assert.NotNil(t, a.server)
	assert.NotNil(t, a.router)
	assert.NotNil(t, a.binder)
	assert.NotNil(t, a.minifier)
	assert.NotNil(t, a.renderer)
	assert.NotNil(t, a.coffer)
	assert.NotNil(t, a.i18n)

	assert.NotNil(t, a.contentTypeSnifferBufferPool)
	assert.IsType(t, []byte{}, a.contentTypeSnifferBufferPool.Get())
	assert.Len(t, a.contentTypeSnifferBufferPool.Get(), 512)
<commit_msg>test: make `TestNew` work before Go 1.12<commit_after>package air

import (
	"bytes"
	"compress/gzip"
	"context"
	"errors"
	"io"
	"io/ioutil"
	"log"
	"net/http"
	"net/http/httptest"
	"os"
	"path"
	"path/filepath"
	"sync"
	"testing"
	"time"

	"github.com/stretchr/testify/assert"
)

func TestNew(t *testing.T) {
	a := New()

	assert.Equal(t, "air", a.AppName)
	assert.Empty(t, a.MaintainerEmail)
	assert.False(t, a.DebugMode)
	assert.Equal(t, ":8080", a.Address)
	assert.Nil(t, a.HostWhitelist)
	assert.Zero(t, a.ReadTimeout)
	assert.Zero(t, a.ReadHeaderTimeout)
	assert.Zero(t, a.WriteTimeout)
	assert.Zero(t, a.IdleTimeout)
	assert.Equal(t, 1048576, a.MaxHeaderBytes)
	assert.Empty(t, a.TLSCertFile)
	assert.Empty(t, a.TLSKeyFile)
	assert.False(t, a.ACMEEnabled)
	assert.Equal(
		t,
		"https://acme-v01.api.letsencrypt.org/directory",
		a.ACMEDirectoryURL,
	)
	assert.Equal(t, "acme-certs", a.ACMECertRoot)
	assert.False(t, a.HTTPSEnforced)
	assert.Zero(t, a.WebSocketHandshakeTimeout)
	assert.Nil(t, a.WebSocketSubprotocols)
	assert.Nil(t, a.Pregases)
	assert.Nil(t, a.Gases)
	assert.IsType(t, DefaultNotFoundHandler, a.NotFoundHandler)
	assert.IsType(
		t,
		DefaultMethodNotAllowedHandler,
		a.MethodNotAllowedHandler,
	)
	assert.IsType(t, DefaultErrorHandler, a.ErrorHandler)
	assert.Nil(t, a.ErrorLogger)
	assert.False(t, a.AutoPushEnabled)
	assert.False(t, a.MinifierEnabled)
	assert.ElementsMatch(t, a.MinifierMIMETypes, []string{
		"text/html",
		"text/css",
		"application/javascript",
		"application/json",
		"application/xml",
		"image/svg+xml",
	})
	assert.False(t, a.GzipEnabled)
	assert.Equal(t, int64(1024), a.GzipMinContentLength)
	assert.ElementsMatch(t, a.GzipMIMETypes, []string{
		"text/plain",
		"text/html",
		"text/css",
		"application/javascript",
		"application/json",
		"application/xml",
		"application/toml",
		"application/yaml",
		"image/svg+xml",
	})
	assert.Equal(t, gzip.DefaultCompression, a.GzipCompressionLevel)
	assert.Equal(t, 8192, a.GzipFlushThreshold)
	assert.Equal(t, "templates", a.RendererTemplateRoot)
	assert.ElementsMatch(t, a.RendererTemplateExts, []string{".html"})
	assert.Equal(t, "{{", a.RendererTemplateLeftDelim)
	assert.Equal(t, "}}", a.RendererTemplateRightDelim)
	assert.Nil(t, a.RendererTemplateFuncMap)
	assert.False(t, a.CofferEnabled)
	assert.Equal(t, 33554432, a.CofferMaxMemoryBytes)
	assert.Equal(t, "assets", a.CofferAssetRoot)
	assert.ElementsMatch(t, a.CofferAssetExts, []string{
		".html",
		".css",
		".js",
		".json",
		".xml",
		".toml",
		".yaml",
		".yml",
		".svg",
		".jpg",
		".jpeg",
		".png",
		".gif",
	})
	assert.False(t, a.I18nEnabled)
	assert.Equal(t, "locales", a.I18nLocaleRoot)
	assert.Equal(t, "en-US", a.I18nLocaleBase)
	assert.Empty(t, a.ConfigFile)

	assert.NotNil(t, a.errorLogger)
	assert.Empty(t, a.errorLogger.Prefix())
	assert.Zero(t, a.errorLogger.Flags())

	assert.NotNil(t, a.server)
	assert.NotNil(t, a.router)
	assert.NotNil(t, a.binder)
	assert.NotNil(t, a.minifier)
	assert.NotNil(t, a.renderer)
	assert.NotNil(t, a.coffer)
	assert.NotNil(t, a.i18n)

	assert.NotNil(t, a.contentTypeSnifferBufferPool)
	assert.IsType(t, []byte{}, a.contentTypeSnifferBufferPool.Get())
	assert.Len(t, a.contentTypeSnifferBufferPool.Get(), 512)

{'fraction_non_alphanumeric': 0.17478421701602959, 'fraction_numerical': 0.01340937114673243, 'mean_word_length': 5.0588235294117645, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, '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': '702899', 'n_tokens_mistral': 2822, 'n_tokens_neox': 2685, 'n_words': 393}