From f18ea412dc8d3a43930bb7f9143dcc2e01d60158 Mon Sep 17 00:00:00 2001 From: Augie Fackler Date: Mon, 2 Nov 2015 15:47:59 -0500 Subject: [PATCH 1/2] config_test: properly detect failed config writes This patch fixes the setup stage of the config tests to notice when the writes fail (eg $PWD is a read-only filesystem) and to correctly skip the entire test function as a result. --- config_test.go | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/config_test.go b/config_test.go index 8c2decc..fea8d8a 100644 --- a/config_test.go +++ b/config_test.go @@ -18,10 +18,22 @@ func setupConfig() (*Config, error) { return nil, err } - c.SetString("foo.bar", "baz") - c.SetBool("foo.bool", true) - c.SetInt32("foo.int32", 32) - c.SetInt64("foo.int64", 64) + err = c.SetString("foo.bar", "baz") + if err != nil { + return nil, err + } + err = c.SetBool("foo.bool", true) + if err != nil { + return nil, err + } + err = c.SetInt32("foo.int32", 32) + if err != nil { + return nil, err + } + err = c.SetInt64("foo.int64", 64) + if err != nil { + return nil, err + } return c, err } @@ -86,6 +98,7 @@ func TestConfigLookups(t *testing.T) { if err != nil { t.Errorf("Setup error: '%v'. Expected none\n", err) + return } defer c.Free() From 714cd56c715d22e9759413783c9c4be0018193e0 Mon Sep 17 00:00:00 2001 From: Augie Fackler Date: Mon, 2 Nov 2015 15:51:03 -0500 Subject: [PATCH 2/2] odb: remove debug fmt.Printlns These appear to be left over debug statements, and they also look like they were intended to be fmt.Printf calls anyway. --- odb.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/odb.go b/odb.go index be0870e..b15851f 100644 --- a/odb.go +++ b/odb.go @@ -11,7 +11,6 @@ import ( "reflect" "runtime" "unsafe" - "fmt" ) type Odb struct { @@ -107,9 +106,7 @@ func odbForEachCb(id *C.git_oid, handle unsafe.Pointer) int { } err := data.callback(newOidFromC(id)) - fmt.Println("err %v", err) if err != nil { - fmt.Println("returning EUSER") data.err = err return C.GIT_EUSER } @@ -130,7 +127,6 @@ func (v *Odb) ForEach(callback OdbForEachCallback) error { defer pointerHandles.Untrack(handle) ret := C._go_git_odb_foreach(v.ptr, handle) - fmt.Println("ret %v", ret); if ret == C.GIT_EUSER { return data.err } else if ret < 0 {