<commit_before>package config

import "testing"
import "time"

func TestNew(t *testing.T) {
	defaults, err := New([]string{})
	if err != nil {
		t.Errorf("Expected no errors")
	}
	if defaults.TCPPort != 8080 {
		t.Errorf("Want TCPPort: 8080, got: %d", defaults.TCPPort)
	}
}

func Test_OperationalMode_Default(t *testing.T) {
	defaults, err := New([]string{})
	if err != nil {
		t.Errorf("Expected no errors")
	}
	if defaults.OperationalMode != ModeStreaming {
		t.Errorf("Want %s. got: %s", WatchdogMode(ModeStreaming), WatchdogMode(defaults.OperationalMode))
	}
}

func Test_OperationalMode_AfterBurn(t *testing.T) {
	env := []string{
		"mode=afterburn",
	}

	actual, err := New(env)
	if err != nil {
		t.Errorf("Expected no errors")
	}

	if actual.OperationalMode != ModeAfterBurn {
		t.Errorf("Want %s. got: %s", WatchdogMode(ModeAfterBurn), WatchdogMode(actual.OperationalMode))
	}

}

func Test_ContentType_Default(t *testing.T) {
	env := []string{}

	actual, err := New(env)
	if err != nil {
		t.Errorf("Expected no errors")
	}

	if actual.ContentType != "application/octet-stream" {
		t.Errorf("Default (ContentType) Want %s. got: %s", actual.ContentType, "octet-stream")
	}
}

func Test_ContentType_Override(t *testing.T) {
	env := []string{
		"content_type=application/json",
	}

	actual, err := New(env)
	if err != nil {
		t.Errorf("Expected no errors")
	}

	if actual.ContentType != "application/json" {
		t.Errorf("(ContentType) Want %s. got: %s", actual.ContentType, "application/json")
	}
}

func Test_FunctionProcessLegacyName(t *testing.T) {
	env := []string{
		"fprocess=env",
	}

	actual, err := New(env)
	if err != nil {
		t.Errorf("Expected no errors")
	}

	if actual.FunctionProcess != "env" {
		t.Errorf("Want %s. got: %s", "env", actual.FunctionProcess)
	}
}

func Test_FunctionProcessAlternativeName(t *testing.T) {
	env := []string{
		"function_process=env",
	}

	actual, err := New(env)
	if err != nil {
		t.Errorf("Expected no errors")
	}

	if actual.FunctionProcess != "env" {
		t.Errorf("Want %s. got: %s", "env", actual.FunctionProcess)
	}
}

func Test_PortOverride(t *testing.T) {
	env := []string{
		"port=8081",
	}

	actual, err := New(env)
	if err != nil {
		t.Errorf("Expected no errors")
	}

	if actual.TCPPort != 8081 {
		t.Errorf("Want %s. got: %s", 8081, actual.TCPPort)
	}
}

func Test_Timeouts(t *testing.T) {
	cases := []struct {
		readTimeout  time.Duration
		writeTimeout time.Duration
		hardTimeout  time.Duration
		env          []string
		name         string
	}{
		{
			name:         "Defaults",
			readTimeout:  time.Second * 10,
			writeTimeout: time.Second * 10,
			hardTimeout:  time.Second * 10,
			env:          []string{},
		},
		{
			name:         "Custom read-timeout",
			readTimeout:  time.Second * 5,
			writeTimeout: time.Second * 10,
			hardTimeout:  time.Second * 10,
			env:          []string{"read_timeout=5s"},
		},
		{
			name:         "Custom write-timeout",
			readTimeout:  time.Second * 10,
			writeTimeout: time.Second * 5,
			hardTimeout:  time.Second * 10,<commit_msg>Use decimal verb for int in fmt format<commit_after>package config

import "testing"
import "time"

func TestNew(t *testing.T) {
	defaults, err := New([]string{})
	if err != nil {
		t.Errorf("Expected no errors")
	}
	if defaults.TCPPort != 8080 {
		t.Errorf("Want TCPPort: 8080, got: %d", defaults.TCPPort)
	}
}

func Test_OperationalMode_Default(t *testing.T) {
	defaults, err := New([]string{})
	if err != nil {
		t.Errorf("Expected no errors")
	}
	if defaults.OperationalMode != ModeStreaming {
		t.Errorf("Want %s. got: %s", WatchdogMode(ModeStreaming), WatchdogMode(defaults.OperationalMode))
	}
}

func Test_OperationalMode_AfterBurn(t *testing.T) {
	env := []string{
		"mode=afterburn",
	}

	actual, err := New(env)
	if err != nil {
		t.Errorf("Expected no errors")
	}

	if actual.OperationalMode != ModeAfterBurn {
		t.Errorf("Want %s. got: %s", WatchdogMode(ModeAfterBurn), WatchdogMode(actual.OperationalMode))
	}

}

func Test_ContentType_Default(t *testing.T) {
	env := []string{}

	actual, err := New(env)
	if err != nil {
		t.Errorf("Expected no errors")
	}

	if actual.ContentType != "application/octet-stream" {
		t.Errorf("Default (ContentType) Want %s. got: %s", actual.ContentType, "octet-stream")
	}
}

func Test_ContentType_Override(t *testing.T) {
	env := []string{
		"content_type=application/json",
	}

	actual, err := New(env)
	if err != nil {
		t.Errorf("Expected no errors")
	}

	if actual.ContentType != "application/json" {
		t.Errorf("(ContentType) Want %s. got: %s", actual.ContentType, "application/json")
	}
}

func Test_FunctionProcessLegacyName(t *testing.T) {
	env := []string{
		"fprocess=env",
	}

	actual, err := New(env)
	if err != nil {
		t.Errorf("Expected no errors")
	}

	if actual.FunctionProcess != "env" {
		t.Errorf("Want %s. got: %s", "env", actual.FunctionProcess)
	}
}

func Test_FunctionProcessAlternativeName(t *testing.T) {
	env := []string{
		"function_process=env",
	}

	actual, err := New(env)
	if err != nil {
		t.Errorf("Expected no errors")
	}

	if actual.FunctionProcess != "env" {
		t.Errorf("Want %s. got: %s", "env", actual.FunctionProcess)
	}
}

func Test_PortOverride(t *testing.T) {
	env := []string{
		"port=8081",
	}

	actual, err := New(env)
	if err != nil {
		t.Errorf("Expected no errors")
	}

	if actual.TCPPort != 8081 {
		t.Errorf("Want %d. got: %d", 8081, actual.TCPPort)
	}
}

func Test_Timeouts(t *testing.T) {
	cases := []struct {
		readTimeout  time.Duration
		writeTimeout time.Duration
		hardTimeout  time.Duration
		env          []string
		name         string
	}{
		{
			name:         "Defaults",
			readTimeout:  time.Second * 10,
			writeTimeout: time.Second * 10,
			hardTimeout:  time.Second * 10,
			env:          []string{},
		},
		{
			name:         "Custom read-timeout",
			readTimeout:  time.Second * 5,
			writeTimeout: time.Second * 10,
			hardTimeout:  time.Second * 10,
			env:          []string{"read_timeout=5s"},
		},
		{
			name:         "Custom write-timeout",
			readTimeout:  time.Second * 10,
			writeTimeout: time.Second * 5,
			hardTimeout:  time.Second * 10,
{'fraction_non_alphanumeric': 0.16014409693794007, 'fraction_numerical': 0.012117242508596693, 'mean_word_length': 3.578710644677661, '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': '4080560', 'n_tokens_mistral': 2414, 'n_tokens_neox': 2199, 'n_words': 502}