File size: 1,114 Bytes
6a7089a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main

import (
	"strings"
	"testing"

	"github.com/pinchtab/pinchtab/internal/config"
)

func TestRenderConfigOverview(t *testing.T) {
	cfg := &config.RuntimeConfig{
		Port:              "9867",
		Strategy:          "simple",
		AllocationPolicy:  "fcfs",
		StealthLevel:      "light",
		TabEvictionPolicy: "close_lru",
		Token:             "very-long-token-secret",
	}
	output := renderConfigOverview(cfg, "/tmp/pinchtab/config.json", "http://localhost:9867", false)

	required := []string{
		"Config",
		"Strategy",
		"Allocation policy",
		"Stealth level",
		"Tab eviction",
		"Copy token",
		"More",
		"/tmp/pinchtab/config.json",
		"very...cret",
		"Dashboard:",
	}
	for _, needle := range required {
		if !strings.Contains(output, needle) {
			t.Fatalf("expected config overview to contain %q\n%s", needle, output)
		}
	}
}

func TestClipboardCommands(t *testing.T) {
	commands := clipboardCommands()
	if len(commands) == 0 {
		t.Fatal("expected clipboard commands")
	}
	for _, command := range commands {
		if command.name == "" {
			t.Fatalf("clipboard command missing name: %+v", command)
		}
	}
}