hg/hgrc_test.go

Wed, 12 Apr 2023 23:40:09 -0500

author
aklitzing <aklitzing@gmail.com>
date
Wed, 12 Apr 2023 23:40:09 -0500
changeset 174
1af17fe86235
parent 105
c675554bfb7b
permissions
-rw-r--r--

Refactor refresh of repositories

Since we use this for other stuff we should split it out from hgweb and
re-use the repository slice for hgweb.

Reviewed at https://reviews.imfreedom.org/r/2434/

package hg

import (
	"testing"

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

func TestFindHgrcsForRepoSimple(t *testing.T) {
	actual := findHgrcsForRepo("grim/hgkeeper")
	expected := []string{
		"config/hgrc",
		"config/grim/hgrc",
		"config/grim/hgkeeper/hgrc",
	}

	assert.Equal(t, expected, actual)
}

func TestFindHgrcsForRepoEmpty(t *testing.T) {
	actual := findHgrcsForRepo("")
	expected := []string{
		"config/hgrc",
	}

	assert.Equal(t, expected, actual)
}

func TestFindHgrcsForRepoDot(t *testing.T) {
	actual := findHgrcsForRepo(".")
	expected := []string{
		"config/hgrc",
	}

	assert.Equal(t, expected, actual)
}

func TestFindHgrcsForRepoAbsolute(t *testing.T) {
	actual := findHgrcsForRepo("/grim/testing/abc123")
	expected := []string{
		"config/hgrc",
		"config/grim/hgrc",
		"config/grim/testing/hgrc",
		"config/grim/testing/abc123/hgrc",
	}

	assert.Equal(t, expected, actual)
}

mercurial