<commit_before>package app_context

import (
	"log"
	"os"
	"testing"
)

func TestTiltEnv(t *testing.T) {
	os.Unsetenv("TILT_ENVIRONMENT")
	app_ctx, err := NewAppContext("basic_test")
	if err != nil {
		log.Fatal(err)
	}
	if tiltEnv := app_ctx.TiltEnv(); tiltEnv != "development" {
		t.Errorf("environment is not development: %s", tiltEnv)
	}

	os.Setenv("TILT_ENVIRONMENT", "testing")

	app_ctx, err = NewAppContext("basic_test")
	if err != nil {
		log.Fatal(err)
	}
	if tiltEnv := app_ctx.TiltEnv(); tiltEnv != "testing" {
		t.Errorf("environment is not testing: %s", tiltEnv)
	}

	os.Setenv("TILT_ENVIRONMENT", "derp")

	app_ctx, err = NewAppContext("basic_test")
	if err == nil {
		t.Error("app context should have failed")
	}
}

func TestCodeVersion(t *testing.T) {
	os.Unsetenv("CODE_VERSION")
	app_ctx, err := NewAppContext("basic_test")<commit_msg>clear the bad environment in the test<commit_after>package app_context

import (
	"log"
	"os"
	"testing"
)

func TestTiltEnv(t *testing.T) {
	os.Unsetenv("TILT_ENVIRONMENT")
	app_ctx, err := NewAppContext("basic_test")
	if err != nil {
		log.Fatal(err)
	}
	if tiltEnv := app_ctx.TiltEnv(); tiltEnv != "development" {
		t.Errorf("environment is not development: %s", tiltEnv)
	}

	os.Setenv("TILT_ENVIRONMENT", "testing")

	app_ctx, err = NewAppContext("basic_test")
	if err != nil {
		log.Fatal(err)
	}
	if tiltEnv := app_ctx.TiltEnv(); tiltEnv != "testing" {
		t.Errorf("environment is not testing: %s", tiltEnv)
	}

	os.Setenv("TILT_ENVIRONMENT", "derp")

	app_ctx, err = NewAppContext("basic_test")
	if err == nil {
		t.Error("app context should have failed")
	}

	os.Unsetenv("TILT_ENVIRONMENT")
}

func TestCodeVersion(t *testing.T) {
	os.Unsetenv("CODE_VERSION")
	app_ctx, err := NewAppContext("basic_test")
{'fraction_non_alphanumeric': 0.1578054298642534, 'fraction_numerical': 0.0, 'mean_word_length': 4.916387959866221, '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': '2327337', 'n_tokens_mistral': 721, 'n_tokens_neox': 695, 'n_words': 142}