From 29ce8ea41348c964d0e95dce9fddd06278a4cd96 Mon Sep 17 00:00:00 2001 From: Matt Brender Date: Mon, 23 May 2016 11:51:52 -0700 Subject: [PATCH] Partial refactor of /plugin tests * Including in each subdirectory * Leaving more complex system testing in until we decide on whether its a medium or throw away for other testing options --- .../snap-collector-mock1/main_small_test.go | 36 +++++++++++++++++++ .../snap-collector-mock1/main_test.go | 7 ---- .../snap-collector-mock2/main_small_test.go | 36 +++++++++++++++++++ .../snap-collector-mock2/main_test.go | 7 ---- .../main_small_test.go | 36 +++++++++++++++++++ .../file/{file_test.go => file_small_test.go} | 2 +- .../snap-publisher-file/main_small_test.go | 36 +++++++++++++++++++ .../snap-publisher-file/main_test.go | 7 ---- 8 files changed, 145 insertions(+), 22 deletions(-) create mode 100644 plugin/collector/snap-collector-mock1/main_small_test.go create mode 100644 plugin/collector/snap-collector-mock2/main_small_test.go create mode 100644 plugin/processor/snap-processor-passthru/main_small_test.go rename plugin/publisher/snap-publisher-file/file/{file_test.go => file_small_test.go} (98%) create mode 100644 plugin/publisher/snap-publisher-file/main_small_test.go diff --git a/plugin/collector/snap-collector-mock1/main_small_test.go b/plugin/collector/snap-collector-mock1/main_small_test.go new file mode 100644 index 000000000..a73f73cb0 --- /dev/null +++ b/plugin/collector/snap-collector-mock1/main_small_test.go @@ -0,0 +1,36 @@ +// +build small + +/* +http://www.apache.org/licenses/LICENSE-2.0.txt + + +Copyright 2015 Intel Corporation + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +import ( + "os" + "testing" + + . "github.com/smartystreets/goconvey/convey" +) + +func TestMain(t *testing.T) { + Convey("ensure plugin loads and responds", t, func() { + os.Args = []string{"", "{\"NoDaemon\": true}"} + So(func() { main() }, ShouldNotPanic) + }) +} diff --git a/plugin/collector/snap-collector-mock1/main_test.go b/plugin/collector/snap-collector-mock1/main_test.go index da85f3179..487e41c92 100644 --- a/plugin/collector/snap-collector-mock1/main_test.go +++ b/plugin/collector/snap-collector-mock1/main_test.go @@ -60,10 +60,3 @@ func TestMockPluginLoad(t *testing.T) { fmt.Printf("SNAP_PATH not set. Cannot test %s plugin.\n", PluginName) } } - -func TestMain(t *testing.T) { - Convey("ensure plugin loads and responds", t, func() { - os.Args = []string{"", "{\"NoDaemon\": true}"} - So(func() { main() }, ShouldNotPanic) - }) -} diff --git a/plugin/collector/snap-collector-mock2/main_small_test.go b/plugin/collector/snap-collector-mock2/main_small_test.go new file mode 100644 index 000000000..a73f73cb0 --- /dev/null +++ b/plugin/collector/snap-collector-mock2/main_small_test.go @@ -0,0 +1,36 @@ +// +build small + +/* +http://www.apache.org/licenses/LICENSE-2.0.txt + + +Copyright 2015 Intel Corporation + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +import ( + "os" + "testing" + + . "github.com/smartystreets/goconvey/convey" +) + +func TestMain(t *testing.T) { + Convey("ensure plugin loads and responds", t, func() { + os.Args = []string{"", "{\"NoDaemon\": true}"} + So(func() { main() }, ShouldNotPanic) + }) +} diff --git a/plugin/collector/snap-collector-mock2/main_test.go b/plugin/collector/snap-collector-mock2/main_test.go index 40e03f4a8..347a7a21a 100644 --- a/plugin/collector/snap-collector-mock2/main_test.go +++ b/plugin/collector/snap-collector-mock2/main_test.go @@ -60,10 +60,3 @@ func TestMockPluginLoad(t *testing.T) { fmt.Printf("SNAP_PATH not set. Cannot test %s plugin.\n", PluginName) } } - -func TestMain(t *testing.T) { - Convey("ensure plugin loads and responds", t, func() { - os.Args = []string{"", "{\"NoDaemon\": true}"} - So(func() { main() }, ShouldNotPanic) - }) -} diff --git a/plugin/processor/snap-processor-passthru/main_small_test.go b/plugin/processor/snap-processor-passthru/main_small_test.go new file mode 100644 index 000000000..a73f73cb0 --- /dev/null +++ b/plugin/processor/snap-processor-passthru/main_small_test.go @@ -0,0 +1,36 @@ +// +build small + +/* +http://www.apache.org/licenses/LICENSE-2.0.txt + + +Copyright 2015 Intel Corporation + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +import ( + "os" + "testing" + + . "github.com/smartystreets/goconvey/convey" +) + +func TestMain(t *testing.T) { + Convey("ensure plugin loads and responds", t, func() { + os.Args = []string{"", "{\"NoDaemon\": true}"} + So(func() { main() }, ShouldNotPanic) + }) +} diff --git a/plugin/publisher/snap-publisher-file/file/file_test.go b/plugin/publisher/snap-publisher-file/file/file_small_test.go similarity index 98% rename from plugin/publisher/snap-publisher-file/file/file_test.go rename to plugin/publisher/snap-publisher-file/file/file_small_test.go index bf8ac689e..c3ab4feab 100644 --- a/plugin/publisher/snap-publisher-file/file/file_test.go +++ b/plugin/publisher/snap-publisher-file/file/file_small_test.go @@ -1,4 +1,4 @@ -// +build legacy +// +build small /* http://www.apache.org/licenses/LICENSE-2.0.txt diff --git a/plugin/publisher/snap-publisher-file/main_small_test.go b/plugin/publisher/snap-publisher-file/main_small_test.go new file mode 100644 index 000000000..a73f73cb0 --- /dev/null +++ b/plugin/publisher/snap-publisher-file/main_small_test.go @@ -0,0 +1,36 @@ +// +build small + +/* +http://www.apache.org/licenses/LICENSE-2.0.txt + + +Copyright 2015 Intel Corporation + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +import ( + "os" + "testing" + + . "github.com/smartystreets/goconvey/convey" +) + +func TestMain(t *testing.T) { + Convey("ensure plugin loads and responds", t, func() { + os.Args = []string{"", "{\"NoDaemon\": true}"} + So(func() { main() }, ShouldNotPanic) + }) +} diff --git a/plugin/publisher/snap-publisher-file/main_test.go b/plugin/publisher/snap-publisher-file/main_test.go index 2b477c60d..ac221a01d 100644 --- a/plugin/publisher/snap-publisher-file/main_test.go +++ b/plugin/publisher/snap-publisher-file/main_test.go @@ -61,10 +61,3 @@ func TestFilePublisherLoad(t *testing.T) { fmt.Printf("SNAP_PATH not set. Cannot test %s plugin.\n", PluginName) } } - -func TestMain(t *testing.T) { - Convey("ensure plugin loads and responds", t, func() { - os.Args = []string{"", "{\"NoDaemon\": true}"} - So(func() { main() }, ShouldNotPanic) - }) -}