File: apt_test.go

package info (click to toggle)
adequate 0.17.6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 488 kB
  • sloc: python: 254; makefile: 111; sh: 75; ansic: 29
file content (36 lines) | stat: -rw-r--r-- 609 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
33
34
35
36
package main

import (
	"bufio"
	"strings"
	"testing"
)

func TestAptHookIsEnabled(t *testing.T) {
	tests := []struct {
		name string
		hook string
		want bool
	}{
		{
			name: "enabled",
			hook: "Adequate::Enabled=true\n\n",
			want: true,
		},
		{
			name: "disabled",
			hook: "Adequate::Enabled=false\n\n",
			want: false,
		},
		{
			name: "undefined",
			hook: "blahblah\nblahblahblah\n\n",
			want: false,
		},
	}
	for _, tt := range tests {
		if got := aptHookIsEnabled(bufio.NewReader(strings.NewReader(tt.hook))); got != tt.want {
			t.Errorf("%s: got %v, want %v", tt.name, got, tt.want)
		}
	}
}