File: load_test.go

package info (click to toggle)
golang-github-xo-terminfo 0.0~git20210125.ca9a967-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 256 kB
  • sloc: sh: 50; makefile: 6
file content (32 lines) | stat: -rw-r--r-- 681 bytes parent folder | download | duplicates (2)
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
package terminfo

import (
	"os"
	"runtime"
	"testing"
)

func TestLoad(t *testing.T) {
	for term, file := range terms(t) {
		err := os.Setenv("TERM", term)
		if err != nil {
			t.Fatalf("could not set TERM environment variable, got: %v", err)
		}

		// open
		ti, err := LoadFromEnv()
		if err != nil {
			t.Fatalf("term %s expected no error, got: %v", term, err)
		}

		// check the name was saved correctly
		if runtime.GOOS != "darwin" && ti.File != file {
			t.Errorf("term %s should have file %s, got: %s", term, file, ti.File)
		}

		// check we have at least one name
		if len(ti.Names) < 1 {
			t.Errorf("term %s expected names to have at least one value", term)
		}
	}
}