github.com/blend/go-sdk@v1.20220411.3/env/is_prodlike_test.go (about) 1 /* 2 3 Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package env_test 9 10 import ( 11 "fmt" 12 "testing" 13 14 "github.com/blend/go-sdk/assert" 15 "github.com/blend/go-sdk/env" 16 "github.com/blend/go-sdk/uuid" 17 ) 18 19 func TestIsProdlike(t *testing.T) { 20 assert := assert.New(t) 21 22 testCases := []struct { 23 Input string 24 Expected bool 25 }{ 26 {Input: env.ServiceEnvDev, Expected: false}, 27 {Input: env.ServiceEnvCI, Expected: false}, 28 {Input: env.ServiceEnvTest, Expected: false}, 29 {Input: env.ServiceEnvSandbox, Expected: false}, 30 {Input: env.ServiceEnvPreprod, Expected: true}, 31 {Input: env.ServiceEnvBeta, Expected: true}, 32 {Input: env.ServiceEnvProd, Expected: true}, 33 {Input: uuid.V4().String(), Expected: true}, 34 {Expected: true}, 35 } 36 37 for _, testCase := range testCases { 38 assert.Equal(testCase.Expected, env.IsProdlike(testCase.Input), fmt.Sprintf("failed for: %s", testCase.Input)) 39 } 40 } 41 42 func TestIsProduction(t *testing.T) { 43 assert := assert.New(t) 44 45 testCases := []struct { 46 Input string 47 Expected bool 48 }{ 49 {Input: env.ServiceEnvDev, Expected: false}, 50 {Input: env.ServiceEnvCI, Expected: false}, 51 {Input: env.ServiceEnvTest, Expected: false}, 52 {Input: env.ServiceEnvSandbox, Expected: false}, 53 {Input: env.ServiceEnvPreprod, Expected: true}, 54 {Input: env.ServiceEnvBeta, Expected: false}, 55 {Input: env.ServiceEnvProd, Expected: true}, 56 {Input: uuid.V4().String(), Expected: false}, 57 {Expected: false}, 58 } 59 60 for _, testCase := range testCases { 61 assert.Equal(testCase.Expected, env.IsProduction(testCase.Input), fmt.Sprintf("failed for: %s", testCase.Input)) 62 } 63 }