aboutsummaryrefslogtreecommitdiffstats
path: root/client/go/internal/admin/vespa-wrapper/logfmt/internal_test.go
blob: d64db5732e758c5296e57676d877fef3804c1763 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package logfmt

import (
	"bufio"
	"os"
	"testing"
)

// tests: func isInternal(componentName string) bool

func TestIsInternal(t *testing.T) {
	f, err := os.Open("internal_names.txt")
	if err != nil {
		t.Fatal("could not read test data")
	}
	defer f.Close()
	for input := bufio.NewScanner(f); input.Scan(); {
		if name := input.Text(); !isInternal(name) {
			t.Logf("name '%s' should be internal but was not recognized", name)
			t.Fail()
		}
	}
	f, err = os.Open("internal_notnames.txt")
	if err != nil {
		t.Fatal("could not read test data")
	}
	defer f.Close()
	for input := bufio.NewScanner(f); input.Scan(); {
		if name := input.Text(); isInternal(name) {
			t.Logf("name '%s' should not be internal but was recognized", name)
			t.Fail()
		}
	}
}