From 1a65dc9da402f6a2b4bd8b20f1f7bcca165b4584 Mon Sep 17 00:00:00 2001 From: Saxon Date: Tue, 12 Nov 2019 22:25:48 +1030 Subject: [PATCH] fixing build errors and testing bugs + removed config_test.go as not relevant anymore --- cmd/revid-cli/main.go | 5 ++- device/raspivid/raspivid.go | 2 +- revid/config/config.go | 1 - revid/config/config_test.go | 73 ------------------------------------- 4 files changed, 4 insertions(+), 77 deletions(-) delete mode 100644 revid/config/config_test.go diff --git a/cmd/revid-cli/main.go b/cmd/revid-cli/main.go index 8a0fbe01..ea031a42 100644 --- a/cmd/revid-cli/main.go +++ b/cmd/revid-cli/main.go @@ -41,6 +41,7 @@ import ( "bitbucket.org/ausocean/av/codec/codecutil" "bitbucket.org/ausocean/av/container/mts" "bitbucket.org/ausocean/av/container/mts/meta" + "bitbucket.org/ausocean/av/device/raspivid" "bitbucket.org/ausocean/av/revid" "bitbucket.org/ausocean/av/revid/config" "bitbucket.org/ausocean/iot/pi/netsender" @@ -129,8 +130,8 @@ func handleFlags() config.Config { rotationPtr = flag.Uint("Rotation", 0, "Rotate video output. (0-359 degrees)") brightnessPtr = flag.Uint("Brightness", 50, "Set brightness. (0-100) ") saturationPtr = flag.Int("Saturation", 0, "Set Saturation. (100-100)") - exposurePtr = flag.String("Exposure", "auto", "Set exposure mode. ("+strings.Join(config.ExposureModes[:], ",")+")") - autoWhiteBalancePtr = flag.String("Awb", "auto", "Set automatic white balance mode. ("+strings.Join(config.AutoWhiteBalanceModes[:], ",")+")") + exposurePtr = flag.String("Exposure", "auto", "Set exposure mode. ("+strings.Join(raspivid.ExposureModes[:], ",")+")") + autoWhiteBalancePtr = flag.String("Awb", "auto", "Set automatic white balance mode. ("+strings.Join(raspivid.AutoWhiteBalanceModes[:], ",")+")") // Audio specific flags. sampleRatePtr = flag.Int("SampleRate", 48000, "Sample rate of recorded audio") diff --git a/device/raspivid/raspivid.go b/device/raspivid/raspivid.go index a805ccfd..9502de4b 100644 --- a/device/raspivid/raspivid.go +++ b/device/raspivid/raspivid.go @@ -175,7 +175,7 @@ func (r *Raspivid) Set(c config.Config) error { c.Saturation = defaultRaspividSaturation } - if c.Exposure == "" || !stringInSlice(c.Exposure, config.ExposureModes[:]) { + if c.Exposure == "" || !stringInSlice(c.Exposure, ExposureModes[:]) { errs = append(errs, errBadExposure) c.Exposure = defaultRaspividExposure } diff --git a/revid/config/config.go b/revid/config/config.go index 04f015e6..74d28618 100644 --- a/revid/config/config.go +++ b/revid/config/config.go @@ -317,7 +317,6 @@ func (c *Config) Validate() error { c.Logger.Log(logger.Info, pkg+"no RTMP URL: falling back to HTTP") c.Outputs[i] = OutputHTTP } - fallthrough default: return errors.New("bad output type defined in config") } diff --git a/revid/config/config_test.go b/revid/config/config_test.go deleted file mode 100644 index 9b6d99ae..00000000 --- a/revid/config/config_test.go +++ /dev/null @@ -1,73 +0,0 @@ -/* -DESCRIPTION - config_test.go provides testing for configuration functionality found in config.go. - -AUTHORS - Saxon A. Nelson-Milton - -LICENSE - Copyright (C) 2019 the Australian Ocean Lab (AusOcean) - - It is free software: you can redistribute it and/or modify them - under the terms of the GNU General Public License as published by the - Free Software Foundation, either version 3 of the License, or (at your - option) any later version. - - It is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - in gpl.txt. If not, see http://www.gnu.org/licenses. -*/ - -package config - -import ( - "fmt" - "testing" -) - -type dumbLogger struct{} - -func (dl *dumbLogger) SetLevel(l int8) {} -func (dl *dumbLogger) Log(l int8, m string, p ...interface{}) {} - -func TestValidate(t *testing.T) { - tests := []struct { - in Config - check func(c Config) error - err error - }{ - { - in: Config{Outputs: []uint8{OutputHTTP}, Quantization: 50, Logger: &dumbLogger{}}, - check: func(c Config) error { return nil }, - err: errInvalidQuantization, - }, - { - in: Config{Outputs: []uint8{OutputHTTP}, Quantization: 20, Logger: &dumbLogger{}}, - check: func(c Config) error { - if c.Bitrate != 0 { - return fmt.Errorf("did not get expected bitrate. Got: %v, Want: %v", c.Bitrate, 0) - } - if c.Quantization != 20 { - return fmt.Errorf("did not get expected quantization. Got: %v, Want: %v", c.Quantization, 20) - } - return nil - }, - }, - } - - for i, test := range tests { - err := (&test.in).Validate() - if err != test.err { - t.Errorf("did not get expected error for test %d\nGot: %v\nWant: %v\n", i, err, test.err) - } - - err = test.check(test.in) - if err != nil { - t.Errorf("test %d failed with err: %v", i, err) - } - } -}