go.temporal.io/server@v1.23.0/common/archiver/metadata_mock_test.go (about) 1 // The MIT License 2 // 3 // Copyright (c) 2020 Temporal Technologies Inc. All rights reserved. 4 // 5 // Copyright (c) 2020 Uber Technologies, Inc. 6 // 7 // Permission is hereby granted, free of charge, to any person obtaining a copy 8 // of this software and associated documentation files (the "Software"), to deal 9 // in the Software without restriction, including without limitation the rights 10 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 // copies of the Software, and to permit persons to whom the Software is 12 // furnished to do so, subject to the following conditions: 13 // 14 // The above copyright notice and this permission notice shall be included in 15 // all copies or substantial portions of the Software. 16 // 17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 // THE SOFTWARE. 24 25 package archiver 26 27 import ( 28 "testing" 29 30 "github.com/golang/mock/gomock" 31 "github.com/stretchr/testify/assert" 32 ) 33 34 func TestMetadataMock(t *testing.T) { 35 t.Run("GetHistoryConfig", func(t *testing.T) { 36 metadata := NewMetadataMock(gomock.NewController(t)) 37 config := metadata.GetHistoryConfig() 38 39 assert.False(t, config.ClusterConfiguredForArchival()) 40 }) 41 t.Run("GetVisibilityConfig", func(t *testing.T) { 42 metadata := NewMetadataMock(gomock.NewController(t)) 43 config := metadata.GetVisibilityConfig() 44 45 assert.False(t, config.ClusterConfiguredForArchival()) 46 }) 47 t.Run("GetHistoryConfig_SetHistoryEnabledByDefault", func(t *testing.T) { 48 metadata := NewMetadataMock(gomock.NewController(t)) 49 metadata.SetHistoryEnabledByDefault() 50 config := metadata.GetHistoryConfig() 51 52 assert.True(t, config.ClusterConfiguredForArchival()) 53 54 metadata.EXPECT().GetHistoryConfig().Return(NewDisabledArchvialConfig()) 55 config = metadata.GetHistoryConfig() 56 57 assert.False(t, config.ClusterConfiguredForArchival()) 58 }) 59 t.Run("GetVisibilityConfig_SetVisibilityEnabledByDefault", func(t *testing.T) { 60 metadata := NewMetadataMock(gomock.NewController(t)) 61 metadata.SetVisibilityEnabledByDefault() 62 config := metadata.GetVisibilityConfig() 63 64 assert.True(t, config.ClusterConfiguredForArchival()) 65 66 metadata.EXPECT().GetVisibilityConfig().Return(NewDisabledArchvialConfig()) 67 config = metadata.GetVisibilityConfig() 68 69 assert.False(t, config.ClusterConfiguredForArchival()) 70 }) 71 t.Run("EXPECT_GetHistoryConfig", func(t *testing.T) { 72 metadata := NewMetadataMock(gomock.NewController(t)) 73 metadata.EXPECT().GetHistoryConfig().Return(NewEnabledArchivalConfig()) 74 config := metadata.GetHistoryConfig() 75 76 assert.True(t, config.ClusterConfiguredForArchival()) 77 78 metadata.EXPECT().GetHistoryConfig().Return(NewDisabledArchvialConfig()) 79 config = metadata.GetHistoryConfig() 80 81 assert.False(t, config.ClusterConfiguredForArchival()) 82 }) 83 84 t.Run("EXPECT_GetVisibilityConfig", func(t *testing.T) { 85 metadata := NewMetadataMock(gomock.NewController(t)) 86 metadata.EXPECT().GetVisibilityConfig().Return(NewEnabledArchivalConfig()) 87 config := metadata.GetVisibilityConfig() 88 89 assert.True(t, config.ClusterConfiguredForArchival()) 90 91 metadata.EXPECT().GetVisibilityConfig().Return(NewDisabledArchvialConfig()) 92 config = metadata.GetVisibilityConfig() 93 94 assert.False(t, config.ClusterConfiguredForArchival()) 95 }) 96 }