| 1 | package gosubmit |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | ) |
| 6 | |
| 7 | func TestFill(t *testing.T) { |
| 8 | hi := HiddenInput{} |
| 9 | _, ok := hi.Fill("test") |
| 10 | if ok == true { |
| 11 | t.Errorf("Should not be able to fill in a hidden input") |
| 12 | } |
| 13 | fi := FileInput{} |
| 14 | _, ok = fi.Fill("test") |
| 15 | if ok == true { |
| 16 | t.Errorf("Should not be able to fill in a file input") |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | func Test_anyinput(t *testing.T) { |
| 21 | a := anyInput{ |
| 22 | name: "test", |
| 23 | inputType: "checkbox", |
| 24 | values: []string{"a", "b"}, |
| 25 | } |
| 26 | if name := a.Name(); name != a.name { |
| 27 | t.Errorf("a.Name() should return %s but got %s", a.name, name) |
| 28 | } |
| 29 | if inputType := a.Type(); inputType != a.inputType { |
| 30 | t.Errorf("a.Type() should return %s but got %s", a.inputType, inputType) |
| 31 | } |
| 32 | if value := a.Value(); value != a.values[0] { |
| 33 | t.Errorf("a.Value() should return first value %s but got %s", a.values[0], value) |
| 34 | } |
| 35 | if size := len(a.Options()); size > 0 { |
| 36 | t.Errorf("a.Options() should always return 0 form this type but got %d", size) |
| 37 | } |
| 38 | } |