File: input_test.go

package info (click to toggle)
golang-github-jeremija-gosubmit 0.2.8-1~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 176 kB
  • sloc: makefile: 7
file content (38 lines) | stat: -rw-r--r-- 954 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
37
38
package gosubmit

import (
	"testing"
)

func TestFill(t *testing.T) {
	hi := HiddenInput{}
	_, ok := hi.Fill("test")
	if ok == true {
		t.Errorf("Should not be able to fill in a hidden input")
	}
	fi := FileInput{}
	_, ok = fi.Fill("test")
	if ok == true {
		t.Errorf("Should not be able to fill in a file input")
	}
}

func Test_anyinput(t *testing.T) {
	a := anyInput{
		name:      "test",
		inputType: "checkbox",
		values:    []string{"a", "b"},
	}
	if name := a.Name(); name != a.name {
		t.Errorf("a.Name() should return %s but got %s", a.name, name)
	}
	if inputType := a.Type(); inputType != a.inputType {
		t.Errorf("a.Type() should return %s but got %s", a.inputType, inputType)
	}
	if value := a.Value(); value != a.values[0] {
		t.Errorf("a.Value() should return first value %s but got %s", a.values[0], value)
	}
	if size := len(a.Options()); size > 0 {
		t.Errorf("a.Options() should always return 0 form this type but got %d", size)
	}
}