From a2da59bf0f0b7f64a9cda4998b2b6a1f6b582506 Mon Sep 17 00:00:00 2001 From: kballou Date: Fri, 17 Apr 2015 15:45:06 -0600 Subject: Add unittests for gohadoopxml Test new function `MergeConfigurations` --- Makefile | 3 +++ gohadoopxml_test.go | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 gohadoopxml_test.go diff --git a/Makefile b/Makefile index e296636..576420d 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,9 @@ build: @mkdir -p _build @go build -ldflags ${LDFLAGS} -o _build/gohadoopxml +test: + @go test + install: @go install -ldflags ${LDFLAGS} diff --git a/gohadoopxml_test.go b/gohadoopxml_test.go new file mode 100644 index 0000000..aa81010 --- /dev/null +++ b/gohadoopxml_test.go @@ -0,0 +1,40 @@ +package gohadoopxml + +import ( + "testing" +) + +func isin(key string, c Configuration) int { + for i, p := range c.Properties { + if p.Name == key { + return i + } + } + return -1 +} + +func TestMergeConfiguration(t *testing.T) { + var config1 = Configuration{ + Properties: []Property{ + { + Name: "foo", + Value: "bar", + }, + }, + } + var config2 = Configuration{ + Properties: []Property{ + { + Name: "fizz", + Value: "buzz", + }, + }, + } + result := MergeConfigurations(config1, config2) + if i := isin("foo", result); i < 0 { + t.Fail() + } + if i := isin("fizz", result); i < 0 { + t.Fail() + } +} -- cgit v1.2.1