<commit_before>package api

import (
	"io/ioutil"
	"testing"
)

func TestValidName(t *testing.T) {
	supposedBad := []string{"£", "-", "-a", "1", "",
		// 41 characters, more than 40
		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}
	supposedGood := []string{"a", "abc-123", "a12345", "abcde", "AbCdE"}
	for _, bad := range supposedBad {
		if ValidName(bad) {
			t.Error(bad + " is not a valid volume/variant name, but it passed ValidName")
		}
	}
	for _, good := range supposedGood {
		if !ValidName(good) {
			t.Error(good + " is a valid volume/variant name, but it failed ValidName")
		}
	}
}

func TestSwitchVolume(t *testing.T) {
	currentVolume := "foo"
	basePath, err := ioutil.TempDir("", "switch")
	if err != nil {
		t.Errorf("Could not create TempDir: %s\n", err)
	}
	dvol := NewDvolAPI(basePath)
	err = dvol.SwitchVolume(currentVolume)
	if err != nil {
		t.Errorf("SwitchVolume failed: %s\n", err)
	}
	activeVolume, err := dvol.ActiveVolume()
	if err != nil {
		t.Error("Could not find ActiveVolume")
	}
	if activeVolume != "foo" {
		t.Errorf("%s is not equal to 'foo'", activeVolume)
	}
}<commit_msg>Pass necessary argument in API tests<commit_after>package api

import (
	"io/ioutil"
	"testing"
)

func TestValidName(t *testing.T) {
	supposedBad := []string{"£", "-", "-a", "1", "",
		// 41 characters, more than 40
		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}
	supposedGood := []string{"a", "abc-123", "a12345", "abcde", "AbCdE"}
	for _, bad := range supposedBad {
		if ValidName(bad) {
			t.Error(bad + " is not a valid volume/variant name, but it passed ValidName")
		}
	}
	for _, good := range supposedGood {
		if !ValidName(good) {
			t.Error(good + " is a valid volume/variant name, but it failed ValidName")
		}
	}
}

func TestSwitchVolume(t *testing.T) {
	currentVolume := "foo"
	basePath, err := ioutil.TempDir("", "switch")
	if err != nil {
		t.Errorf("Could not create TempDir: %s\n", err)
	}
	disableDockerIntegration := true
	dvol := NewDvolAPI(basePath, disableDockerIntegration)
	err = dvol.SwitchVolume(currentVolume)
	if err != nil {
		t.Errorf("SwitchVolume failed: %s\n", err)
	}
	activeVolume, err := dvol.ActiveVolume()
	if err != nil {
		t.Error("Could not find ActiveVolume")
	}
	if activeVolume != "foo" {
		t.Errorf("%s is not equal to 'foo'", activeVolume)
	}
}
{'fraction_non_alphanumeric': 0.1632564214192425, 'fraction_numerical': 0.011319111885067479, 'mean_word_length': 4.095343680709535, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '6158264', 'n_tokens_mistral': 873, 'n_tokens_neox': 823, 'n_words': 220}