@ -89,6 +89,8 @@ func (suite *ServerTestSuite) TestHealthRoute() {
mockCtrl := gomock . NewController ( suite . T ( ) )
defer mockCtrl . Finish ( )
fakeConfig := mock_config . NewMockInterface ( mockCtrl )
fakeConfig . EXPECT ( ) . Set ( gomock . Any ( ) , gomock . Any ( ) ) . AnyTimes ( )
fakeConfig . EXPECT ( ) . UnmarshalKey ( gomock . Any ( ) , gomock . Any ( ) ) . AnyTimes ( ) . Return ( nil )
fakeConfig . EXPECT ( ) . GetString ( "web.database.location" ) . Return ( path . Join ( parentPath , "scrutiny_test.db" ) ) . AnyTimes ( )
fakeConfig . EXPECT ( ) . GetString ( "web.src.frontend.path" ) . Return ( parentPath ) . AnyTimes ( )
fakeConfig . EXPECT ( ) . GetString ( "web.listen.basepath" ) . Return ( suite . Basepath ) . AnyTimes ( )
@ -130,6 +132,8 @@ func (suite *ServerTestSuite) TestRegisterDevicesRoute() {
mockCtrl := gomock . NewController ( suite . T ( ) )
defer mockCtrl . Finish ( )
fakeConfig := mock_config . NewMockInterface ( mockCtrl )
fakeConfig . EXPECT ( ) . Set ( gomock . Any ( ) , gomock . Any ( ) ) . AnyTimes ( )
fakeConfig . EXPECT ( ) . UnmarshalKey ( gomock . Any ( ) , gomock . Any ( ) ) . AnyTimes ( ) . Return ( nil )
fakeConfig . EXPECT ( ) . GetString ( "web.database.location" ) . Return ( path . Join ( parentPath , "scrutiny_test.db" ) ) . AnyTimes ( )
fakeConfig . EXPECT ( ) . GetString ( "web.src.frontend.path" ) . Return ( parentPath ) . AnyTimes ( )
fakeConfig . EXPECT ( ) . GetString ( "web.listen.basepath" ) . Return ( suite . Basepath ) . AnyTimes ( )
@ -170,6 +174,8 @@ func (suite *ServerTestSuite) TestUploadDeviceMetricsRoute() {
mockCtrl := gomock . NewController ( suite . T ( ) )
defer mockCtrl . Finish ( )
fakeConfig := mock_config . NewMockInterface ( mockCtrl )
fakeConfig . EXPECT ( ) . Set ( gomock . Any ( ) , gomock . Any ( ) ) . AnyTimes ( )
fakeConfig . EXPECT ( ) . UnmarshalKey ( gomock . Any ( ) , gomock . Any ( ) ) . AnyTimes ( ) . Return ( nil )
fakeConfig . EXPECT ( ) . GetString ( "web.database.location" ) . AnyTimes ( ) . Return ( path . Join ( parentPath , "scrutiny_test.db" ) )
fakeConfig . EXPECT ( ) . GetString ( "web.src.frontend.path" ) . AnyTimes ( ) . Return ( parentPath )
fakeConfig . EXPECT ( ) . GetString ( "web.listen.basepath" ) . Return ( suite . Basepath ) . AnyTimes ( )
@ -186,8 +192,9 @@ func (suite *ServerTestSuite) TestUploadDeviceMetricsRoute() {
} else {
fakeConfig . EXPECT ( ) . GetString ( "web.influxdb.host" ) . Return ( "localhost" ) . AnyTimes ( )
}
fakeConfig . EXPECT ( ) . GetString ( "notify.level" ) . AnyTimes ( ) . Return ( pkg . NotifyLevelFail )
fakeConfig . EXPECT ( ) . GetString ( "notify.filter_attributes" ) . AnyTimes ( ) . Return ( pkg . NotifyFilterAttributesAll )
fakeConfig . EXPECT ( ) . GetInt ( "dbsetting.metrics.notify.level" ) . AnyTimes ( ) . Return ( int ( pkg . MetricsNotifyLevelFail ) )
fakeConfig . EXPECT ( ) . GetInt ( "dbsetting.metrics.status.filter_attributes" ) . AnyTimes ( ) . Return ( int ( pkg . MetricsStatusFilterAttributesAll ) )
fakeConfig . EXPECT ( ) . GetInt ( "dbsetting.metrics.status.threshold" ) . AnyTimes ( ) . Return ( int ( pkg . MetricsStatusThresholdBoth ) )
ae := web . AppEngine {
Config : fakeConfig ,
@ -219,10 +226,13 @@ func (suite *ServerTestSuite) TestPopulateMultiple() {
mockCtrl := gomock . NewController ( suite . T ( ) )
defer mockCtrl . Finish ( )
fakeConfig := mock_config . NewMockInterface ( mockCtrl )
fakeConfig . EXPECT ( ) . Set ( gomock . Any ( ) , gomock . Any ( ) ) . AnyTimes ( )
fakeConfig . EXPECT ( ) . UnmarshalKey ( gomock . Any ( ) , gomock . Any ( ) ) . AnyTimes ( ) . Return ( nil )
//fakeConfig.EXPECT().GetString("web.database.location").AnyTimes().Return("testdata/scrutiny_test.db")
fakeConfig . EXPECT ( ) . GetStringSlice ( "notify.urls" ) . Return ( [ ] string { } ) . AnyTimes ( )
fakeConfig . EXPECT ( ) . GetString ( "notify.level" ) . AnyTimes ( ) . Return ( pkg . NotifyLevelFail )
fakeConfig . EXPECT ( ) . GetString ( "notify.filter_attributes" ) . AnyTimes ( ) . Return ( pkg . NotifyFilterAttributesAll )
fakeConfig . EXPECT ( ) . GetInt ( "dbsetting.metrics.notify.level" ) . AnyTimes ( ) . Return ( int ( pkg . MetricsNotifyLevelFail ) )
fakeConfig . EXPECT ( ) . GetInt ( "dbsetting.metrics.status.filter_attributes" ) . AnyTimes ( ) . Return ( int ( pkg . MetricsStatusFilterAttributesAll ) )
fakeConfig . EXPECT ( ) . GetInt ( "dbsetting.metrics.status.threshold" ) . AnyTimes ( ) . Return ( int ( pkg . MetricsStatusThresholdBoth ) )
fakeConfig . EXPECT ( ) . GetString ( "web.database.location" ) . AnyTimes ( ) . Return ( path . Join ( parentPath , "scrutiny_test.db" ) )
fakeConfig . EXPECT ( ) . GetString ( "web.src.frontend.path" ) . AnyTimes ( ) . Return ( parentPath )
fakeConfig . EXPECT ( ) . GetString ( "web.listen.basepath" ) . Return ( suite . Basepath ) . AnyTimes ( )
@ -319,6 +329,8 @@ func (suite *ServerTestSuite) TestSendTestNotificationRoute_WebhookFailure() {
mockCtrl := gomock . NewController ( suite . T ( ) )
defer mockCtrl . Finish ( )
fakeConfig := mock_config . NewMockInterface ( mockCtrl )
fakeConfig . EXPECT ( ) . Set ( gomock . Any ( ) , gomock . Any ( ) ) . AnyTimes ( )
fakeConfig . EXPECT ( ) . UnmarshalKey ( gomock . Any ( ) , gomock . Any ( ) ) . AnyTimes ( ) . Return ( nil )
fakeConfig . EXPECT ( ) . GetString ( "web.database.location" ) . AnyTimes ( ) . Return ( path . Join ( parentPath , "scrutiny_test.db" ) )
fakeConfig . EXPECT ( ) . GetString ( "web.src.frontend.path" ) . AnyTimes ( ) . Return ( parentPath )
fakeConfig . EXPECT ( ) . GetString ( "web.listen.basepath" ) . Return ( suite . Basepath ) . AnyTimes ( )
@ -330,8 +342,9 @@ func (suite *ServerTestSuite) TestSendTestNotificationRoute_WebhookFailure() {
fakeConfig . EXPECT ( ) . GetString ( "web.influxdb.bucket" ) . Return ( "metrics" ) . AnyTimes ( )
fakeConfig . EXPECT ( ) . GetBool ( "web.influxdb.retention_policy" ) . Return ( false ) . AnyTimes ( )
fakeConfig . EXPECT ( ) . GetStringSlice ( "notify.urls" ) . AnyTimes ( ) . Return ( [ ] string { "https://unroutable.domain.example.asdfghj" } )
fakeConfig . EXPECT ( ) . GetString ( "notify.level" ) . AnyTimes ( ) . Return ( pkg . NotifyLevelFail )
fakeConfig . EXPECT ( ) . GetString ( "notify.filter_attributes" ) . AnyTimes ( ) . Return ( pkg . NotifyFilterAttributesAll )
fakeConfig . EXPECT ( ) . GetInt ( "dbsetting.metrics.notify.level" ) . AnyTimes ( ) . Return ( int ( pkg . MetricsNotifyLevelFail ) )
fakeConfig . EXPECT ( ) . GetInt ( "dbsetting.metrics.status.filter_attributes" ) . AnyTimes ( ) . Return ( int ( pkg . MetricsStatusFilterAttributesAll ) )
fakeConfig . EXPECT ( ) . GetInt ( "dbsetting.metrics.status.threshold" ) . AnyTimes ( ) . Return ( int ( pkg . MetricsStatusThresholdBoth ) )
if _ , isGithubActions := os . LookupEnv ( "GITHUB_ACTIONS" ) ; isGithubActions {
// when running test suite in github actions, we run an influxdb service as a sidecar.
@ -361,6 +374,8 @@ func (suite *ServerTestSuite) TestSendTestNotificationRoute_ScriptFailure() {
mockCtrl := gomock . NewController ( suite . T ( ) )
defer mockCtrl . Finish ( )
fakeConfig := mock_config . NewMockInterface ( mockCtrl )
fakeConfig . EXPECT ( ) . Set ( gomock . Any ( ) , gomock . Any ( ) ) . AnyTimes ( )
fakeConfig . EXPECT ( ) . UnmarshalKey ( gomock . Any ( ) , gomock . Any ( ) ) . AnyTimes ( ) . Return ( nil )
fakeConfig . EXPECT ( ) . GetString ( "web.database.location" ) . AnyTimes ( ) . Return ( path . Join ( parentPath , "scrutiny_test.db" ) )
fakeConfig . EXPECT ( ) . GetString ( "web.src.frontend.path" ) . AnyTimes ( ) . Return ( parentPath )
fakeConfig . EXPECT ( ) . GetString ( "web.listen.basepath" ) . Return ( suite . Basepath ) . AnyTimes ( )
@ -372,8 +387,9 @@ func (suite *ServerTestSuite) TestSendTestNotificationRoute_ScriptFailure() {
fakeConfig . EXPECT ( ) . GetString ( "web.influxdb.bucket" ) . Return ( "metrics" ) . AnyTimes ( )
fakeConfig . EXPECT ( ) . GetBool ( "web.influxdb.retention_policy" ) . Return ( false ) . AnyTimes ( )
fakeConfig . EXPECT ( ) . GetStringSlice ( "notify.urls" ) . AnyTimes ( ) . Return ( [ ] string { "script:///missing/path/on/disk" } )
fakeConfig . EXPECT ( ) . GetString ( "notify.level" ) . AnyTimes ( ) . Return ( pkg . NotifyLevelFail )
fakeConfig . EXPECT ( ) . GetString ( "notify.filter_attributes" ) . AnyTimes ( ) . Return ( pkg . NotifyFilterAttributesAll )
fakeConfig . EXPECT ( ) . GetInt ( "dbsetting.metrics.notify.level" ) . AnyTimes ( ) . Return ( int ( pkg . MetricsNotifyLevelFail ) )
fakeConfig . EXPECT ( ) . GetInt ( "dbsetting.metrics.status.filter_attributes" ) . AnyTimes ( ) . Return ( int ( pkg . MetricsStatusFilterAttributesAll ) )
fakeConfig . EXPECT ( ) . GetInt ( "dbsetting.metrics.status.threshold" ) . AnyTimes ( ) . Return ( int ( pkg . MetricsStatusThresholdBoth ) )
if _ , isGithubActions := os . LookupEnv ( "GITHUB_ACTIONS" ) ; isGithubActions {
// when running test suite in github actions, we run an influxdb service as a sidecar.
@ -403,6 +419,8 @@ func (suite *ServerTestSuite) TestSendTestNotificationRoute_ScriptSuccess() {
mockCtrl := gomock . NewController ( suite . T ( ) )
defer mockCtrl . Finish ( )
fakeConfig := mock_config . NewMockInterface ( mockCtrl )
fakeConfig . EXPECT ( ) . Set ( gomock . Any ( ) , gomock . Any ( ) ) . AnyTimes ( )
fakeConfig . EXPECT ( ) . UnmarshalKey ( gomock . Any ( ) , gomock . Any ( ) ) . AnyTimes ( ) . Return ( nil )
fakeConfig . EXPECT ( ) . GetString ( "web.database.location" ) . AnyTimes ( ) . Return ( path . Join ( parentPath , "scrutiny_test.db" ) )
fakeConfig . EXPECT ( ) . GetString ( "web.src.frontend.path" ) . AnyTimes ( ) . Return ( parentPath )
fakeConfig . EXPECT ( ) . GetString ( "web.listen.basepath" ) . Return ( suite . Basepath ) . AnyTimes ( )
@ -414,8 +432,9 @@ func (suite *ServerTestSuite) TestSendTestNotificationRoute_ScriptSuccess() {
fakeConfig . EXPECT ( ) . GetString ( "web.influxdb.bucket" ) . Return ( "metrics" ) . AnyTimes ( )
fakeConfig . EXPECT ( ) . GetBool ( "web.influxdb.retention_policy" ) . Return ( false ) . AnyTimes ( )
fakeConfig . EXPECT ( ) . GetStringSlice ( "notify.urls" ) . AnyTimes ( ) . Return ( [ ] string { "script:///usr/bin/env" } )
fakeConfig . EXPECT ( ) . GetString ( "notify.level" ) . AnyTimes ( ) . Return ( pkg . NotifyLevelFail )
fakeConfig . EXPECT ( ) . GetString ( "notify.filter_attributes" ) . AnyTimes ( ) . Return ( pkg . NotifyFilterAttributesAll )
fakeConfig . EXPECT ( ) . GetInt ( "dbsetting.metrics.notify.level" ) . AnyTimes ( ) . Return ( int ( pkg . MetricsNotifyLevelFail ) )
fakeConfig . EXPECT ( ) . GetInt ( "dbsetting.metrics.status.filter_attributes" ) . AnyTimes ( ) . Return ( int ( pkg . MetricsStatusFilterAttributesAll ) )
fakeConfig . EXPECT ( ) . GetInt ( "dbsetting.metrics.status.threshold" ) . AnyTimes ( ) . Return ( int ( pkg . MetricsStatusThresholdBoth ) )
if _ , isGithubActions := os . LookupEnv ( "GITHUB_ACTIONS" ) ; isGithubActions {
// when running test suite in github actions, we run an influxdb service as a sidecar.
@ -445,6 +464,8 @@ func (suite *ServerTestSuite) TestSendTestNotificationRoute_ShoutrrrFailure() {
mockCtrl := gomock . NewController ( suite . T ( ) )
defer mockCtrl . Finish ( )
fakeConfig := mock_config . NewMockInterface ( mockCtrl )
fakeConfig . EXPECT ( ) . Set ( gomock . Any ( ) , gomock . Any ( ) ) . AnyTimes ( )
fakeConfig . EXPECT ( ) . UnmarshalKey ( gomock . Any ( ) , gomock . Any ( ) ) . AnyTimes ( ) . Return ( nil )
fakeConfig . EXPECT ( ) . GetString ( "web.database.location" ) . AnyTimes ( ) . Return ( path . Join ( parentPath , "scrutiny_test.db" ) )
fakeConfig . EXPECT ( ) . GetString ( "web.src.frontend.path" ) . AnyTimes ( ) . Return ( parentPath )
fakeConfig . EXPECT ( ) . GetString ( "web.listen.basepath" ) . Return ( suite . Basepath ) . AnyTimes ( )
@ -456,8 +477,9 @@ func (suite *ServerTestSuite) TestSendTestNotificationRoute_ShoutrrrFailure() {
fakeConfig . EXPECT ( ) . GetString ( "web.influxdb.bucket" ) . Return ( "metrics" ) . AnyTimes ( )
fakeConfig . EXPECT ( ) . GetBool ( "web.influxdb.retention_policy" ) . Return ( false ) . AnyTimes ( )
fakeConfig . EXPECT ( ) . GetStringSlice ( "notify.urls" ) . AnyTimes ( ) . Return ( [ ] string { "discord://invalidtoken@channel" } )
fakeConfig . EXPECT ( ) . GetString ( "notify.level" ) . AnyTimes ( ) . Return ( pkg . NotifyLevelFail )
fakeConfig . EXPECT ( ) . GetString ( "notify.filter_attributes" ) . AnyTimes ( ) . Return ( pkg . NotifyFilterAttributesAll )
fakeConfig . EXPECT ( ) . GetInt ( "dbsetting.metrics.notify.level" ) . AnyTimes ( ) . Return ( int ( pkg . MetricsNotifyLevelFail ) )
fakeConfig . EXPECT ( ) . GetInt ( "dbsetting.metrics.status.filter_attributes" ) . AnyTimes ( ) . Return ( int ( pkg . MetricsStatusFilterAttributesAll ) )
fakeConfig . EXPECT ( ) . GetInt ( "dbsetting.metrics.status.threshold" ) . AnyTimes ( ) . Return ( int ( pkg . MetricsStatusThresholdBoth ) )
if _ , isGithubActions := os . LookupEnv ( "GITHUB_ACTIONS" ) ; isGithubActions {
// when running test suite in github actions, we run an influxdb service as a sidecar.
@ -486,6 +508,8 @@ func (suite *ServerTestSuite) TestGetDevicesSummaryRoute_Nvme() {
mockCtrl := gomock . NewController ( suite . T ( ) )
defer mockCtrl . Finish ( )
fakeConfig := mock_config . NewMockInterface ( mockCtrl )
fakeConfig . EXPECT ( ) . Set ( gomock . Any ( ) , gomock . Any ( ) ) . AnyTimes ( )
fakeConfig . EXPECT ( ) . UnmarshalKey ( gomock . Any ( ) , gomock . Any ( ) ) . AnyTimes ( ) . Return ( nil )
fakeConfig . EXPECT ( ) . GetString ( "web.database.location" ) . AnyTimes ( ) . Return ( path . Join ( parentPath , "scrutiny_test.db" ) )
fakeConfig . EXPECT ( ) . GetString ( "web.src.frontend.path" ) . AnyTimes ( ) . Return ( parentPath )
fakeConfig . EXPECT ( ) . GetString ( "web.listen.basepath" ) . Return ( suite . Basepath ) . AnyTimes ( )
@ -497,8 +521,10 @@ func (suite *ServerTestSuite) TestGetDevicesSummaryRoute_Nvme() {
fakeConfig . EXPECT ( ) . GetString ( "web.influxdb.bucket" ) . Return ( "metrics" ) . AnyTimes ( )
fakeConfig . EXPECT ( ) . GetBool ( "web.influxdb.retention_policy" ) . Return ( false ) . AnyTimes ( )
fakeConfig . EXPECT ( ) . GetStringSlice ( "notify.urls" ) . AnyTimes ( ) . Return ( [ ] string { } )
fakeConfig . EXPECT ( ) . GetString ( "notify.level" ) . AnyTimes ( ) . Return ( pkg . NotifyLevelFail )
fakeConfig . EXPECT ( ) . GetString ( "notify.filter_attributes" ) . AnyTimes ( ) . Return ( pkg . NotifyFilterAttributesAll )
fakeConfig . EXPECT ( ) . GetInt ( "dbsetting.metrics.notify.level" ) . AnyTimes ( ) . Return ( int ( pkg . MetricsNotifyLevelFail ) )
fakeConfig . EXPECT ( ) . GetInt ( "dbsetting.metrics.status.filter_attributes" ) . AnyTimes ( ) . Return ( int ( pkg . MetricsStatusFilterAttributesAll ) )
fakeConfig . EXPECT ( ) . GetInt ( "dbsetting.metrics.status.threshold" ) . AnyTimes ( ) . Return ( int ( pkg . MetricsStatusThresholdBoth ) )
if _ , isGithubActions := os . LookupEnv ( "GITHUB_ACTIONS" ) ; isGithubActions {
// when running test suite in github actions, we run an influxdb service as a sidecar.
fakeConfig . EXPECT ( ) . GetString ( "web.influxdb.host" ) . Return ( "influxdb" ) . AnyTimes ( )