summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Steinert <[email protected]>2015-03-30 18:26:47 -0500
committerMichael Steinert <[email protected]>2015-03-30 18:26:47 -0500
commit8fad6141759baefd2eb2a328cfd573996df3e2cf (patch)
tree2e027ce33dbea57e5bec70ad1f7de203b7faf7c6
parent3215d873b90d1aa132c368eae2b5273d20686359 (diff)
Test coverage for SetItem/GetItem
-rw-r--r--transaction_test.go36
1 files changed, 35 insertions, 1 deletions
diff --git a/transaction_test.go b/transaction_test.go
index 6515eaa..3826bf4 100644
--- a/transaction_test.go
+++ b/transaction_test.go
@@ -98,7 +98,41 @@ func TestPAM_004(t *testing.T) {
}
}
-func TestGetEnvList(t *testing.T) {
+func TestItem(t *testing.T) {
+ tx, err := StartFunc("passwd", "test", func(s Style, msg string) (string, error) {
+ return "", nil
+ })
+
+ s, err := tx.GetItem(Service)
+ if err != nil {
+ t.Fatalf("getitem #error: %v", err)
+ }
+ if s != "passwd" {
+ t.Fatalf("getitem #error: expected passwd, got %v", s)
+ }
+
+ s, err = tx.GetItem(User)
+ if err != nil {
+ t.Fatalf("getitem #error: %v", err)
+ }
+ if s != "test" {
+ t.Fatalf("getitem #error: expected test, got %v", s)
+ }
+
+ err = tx.SetItem(User, "root")
+ if err != nil {
+ t.Fatalf("setitem #error: %v", err)
+ }
+ s, err = tx.GetItem(User)
+ if err != nil {
+ t.Fatalf("getitem #error: %v", err)
+ }
+ if s != "root" {
+ t.Fatalf("getitem #error: expected root, got %v", s)
+ }
+}
+
+func TestEnv(t *testing.T) {
tx, err := StartFunc("", "", func(s Style, msg string) (string, error) {
return "", nil
})