<commit_before>package router

import "testing"


//Test that when removing an alias that only the single alias is removed and not the entire host alias structure for the
//frontend
func TestRemoveAlias(t *testing.T){
	router := &Routes{
		make(map[string]Frontend),
	}

	router.AddAlias("alias1", "frontend1")
	router.AddAlias("alias2", "frontend1")

	frontend := router.GlobalRoutes["frontend1"]

	if len(frontend.HostAliases) != 2{
		t.Error("Expected 2 aliases got %i", len(frontend.HostAliases))
	}

	router.RemoveAlias("alias1", "frontend1")

	frontend = router.GlobalRoutes["frontend1"]

	if len(frontend.HostAliases) != 1 {
		t.Error("Expected 1 aliases got %i", len(frontend.HostAliases))
	}

	alias := frontend.HostAliases[0]

	if alias != "alias2"{
		t.Error("Expected to have alias2 remaining, found %s", alias)
	}
}

//test deleting a frontend removes it from global routes
func TestDeleteFrontend(t *testing.T){
	router := &Routes{
		make(map[string]Frontend),
	}

	router.AddAlias("alias1", "frontend1")

	frontend, ok := router.GlobalRoutes["frontend1"]

	if !ok {
		t.Error("Expected to find frontend")
	}

	if len(frontend.HostAliases) != 1{
		t.Error("Expected 1 host alias")
	}

	router.DeleteFrontend("frontend1")
<commit_msg>gofmt<commit_after>package router

import "testing"

//Test that when removing an alias that only the single alias is removed and not the entire host alias structure for the
//frontend
func TestRemoveAlias(t *testing.T) {
	router := &Routes{
		make(map[string]Frontend),
	}

	router.AddAlias("alias1", "frontend1")
	router.AddAlias("alias2", "frontend1")

	frontend := router.GlobalRoutes["frontend1"]

	if len(frontend.HostAliases) != 2 {
		t.Error("Expected 2 aliases got %i", len(frontend.HostAliases))
	}

	router.RemoveAlias("alias1", "frontend1")

	frontend = router.GlobalRoutes["frontend1"]

	if len(frontend.HostAliases) != 1 {
		t.Error("Expected 1 aliases got %i", len(frontend.HostAliases))
	}

	alias := frontend.HostAliases[0]

	if alias != "alias2" {
		t.Error("Expected to have alias2 remaining, found %s", alias)
	}
}

//test deleting a frontend removes it from global routes
func TestDeleteFrontend(t *testing.T) {
	router := &Routes{
		make(map[string]Frontend),
	}

	router.AddAlias("alias1", "frontend1")

	frontend, ok := router.GlobalRoutes["frontend1"]

	if !ok {
		t.Error("Expected to find frontend")
	}

	if len(frontend.HostAliases) != 1 {
		t.Error("Expected 1 host alias")
	}

	router.DeleteFrontend("frontend1")

{'fraction_non_alphanumeric': 0.1389558232931727, 'fraction_numerical': 0.016867469879518072, 'mean_word_length': 4.888888888888889, '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': '2455560', 'n_tokens_mistral': 914, 'n_tokens_neox': 856, 'n_words': 216}