package narcissus

import (
	"testing"

	"honnef.co/go/augeas"
)

type foo struct {
	A string `path:"a"`
}

func TestParseNotAPtr(t *testing.T) {
	n := New(&augeas.Augeas{})
	err := n.Parse(foo{}, "/files/some/path")

	if err == nil {
		t.Error("Expected an error, got nothing")
	}

	if err.Error() != "not a ptr" {
		t.Errorf("Expected error not a ptr, got %s", err.Error())
	}
}

func TestParseNotAStruct(t *testing.T) {
	n := New(&augeas.Augeas{})
	f := "foo"
	err := n.Parse(&f, "/files/some/path")

	if err == nil {
		t.Error("Expected an error, got nothing")
	}

	if err.Error() != "not a struct" {
		t.Errorf("Expected error not a struct, got %s", err.Error())
	}
}

func TestParseFieldNotFound(t *testing.T) {
	n := New(&augeas.Augeas{})
	t.Skip("This causes a segfault with the Augeas lib. Open a bug!")
	err := n.Parse(&foo{}, "/files/some/path")

	if err == nil {
		t.Error("Expected an error, got nothing")
	}
}

package narcissus

import (
	"testing"

	"honnef.co/go/augeas"
)

type foo struct {
}

func TestParseNotAPtr(t *testing.T) {
	n := New(&augeas.Augeas{})
	err := n.Parse(foo{}, "/files/some/path")

	if err == nil {
		t.Error("Expected an error, got nothing")
	}

	if err.Error() != "not a ptr" {
		t.Errorf("Expected error not a ptr, got %s", err.Error())
	}
}

func TestParseNotAStruct(t *testing.T) {
	n := New(&augeas.Augeas{})
	f := "foo"
	err := n.Parse(&f, "/files/some/path")

	if err == nil {
		t.Error("Expected an error, got nothing")
	}

	if err.Error() != "not a struct" {
		t.Errorf("Expected error not a struct, got %s", err.Error())
	}
}

--- 
+++ 
@@ -7,6 +7,7 @@
 )
 
 type foo struct {
+	A string `path:"a"`
 }
 
 func TestParseNotAPtr(t *testing.T) {
@@ -35,3 +36,13 @@
 		t.Errorf("Expected error not a struct, got %s", err.Error())
 	}
 }
+
+func TestParseFieldNotFound(t *testing.T) {
+	n := New(&augeas.Augeas{})
+	t.Skip("This causes a segfault with the Augeas lib. Open a bug!")
+	err := n.Parse(&foo{}, "/files/some/path")
+
+	if err == nil {
+		t.Error("Expected an error, got nothing")
+	}
+}
Add test for field not found (currently failing)
