-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package consoleout | ||
|
||
import "testing" | ||
|
||
// TestName ensures we can lookup a driver by name | ||
func TestName(t *testing.T) { | ||
|
||
valid := []string{"ansi", "adm-3a"} | ||
|
||
for _, nm := range valid { | ||
|
||
d, e := New(nm) | ||
if e != nil { | ||
t.Fatalf("failed to lookup driver by name %s:%s", nm, e) | ||
} | ||
if d.GetName() != nm { | ||
t.Fatalf("%s != %s", d.GetName(), nm) | ||
} | ||
} | ||
|
||
// Lookup a driver that wont exist | ||
_, err := New("foo.bar.ba") | ||
if err == nil { | ||
t.Fatalf("we got a driver that shouldn't exist") | ||
} | ||
} | ||
|
||
// TestChangeDriver ensures we can change a driver | ||
func TestChangeDriver(t *testing.T) { | ||
|
||
// Start with a known-good driver | ||
ansi, err := New("ansi") | ||
if err != nil { | ||
t.Fatalf("failed to load starting driver %s", err) | ||
} | ||
|
||
// Change to another known-good driver | ||
err = ansi.ChangeDriver("adm-3a") | ||
if err != nil { | ||
t.Fatalf("failed to change to new driver %s", err) | ||
} | ||
if ansi.GetName() != "adm-3a" { | ||
t.Fatalf("driver change didnt work?") | ||
} | ||
|
||
// Change to a bogus driver | ||
err = ansi.ChangeDriver("fofdsf-fsdfsd-fsdfdsf-") | ||
if err == nil { | ||
t.Fatalf("expected failure to change to new driver, didn't happen") | ||
} | ||
if ansi.GetName() != "adm-3a" { | ||
t.Fatalf("driver changed unexpectedly") | ||
} | ||
} |