github.com/blend/go-sdk@v1.20220411.3/env/is_dev_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 TestIsDevlike(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.IsDevlike(testCase.Input), fmt.Sprintf("failed for: %s", testCase.Input))
    39  	}
    40  }
    41  
    42  func TestIsDev(t *testing.T) {
    43  	assert := assert.New(t)
    44  
    45  	testCases := []struct {
    46  		Input    string
    47  		Expected bool
    48  	}{
    49  		{Input: env.ServiceEnvDev, Expected: true},
    50  		{Input: env.ServiceEnvCI, Expected: false},
    51  		{Input: env.ServiceEnvTest, Expected: false},
    52  		{Input: env.ServiceEnvSandbox, Expected: false},
    53  		{Input: env.ServiceEnvPreprod, Expected: false},
    54  		{Input: env.ServiceEnvBeta, Expected: false},
    55  		{Input: env.ServiceEnvProd, Expected: false},
    56  		{Input: uuid.V4().String(), Expected: false},
    57  		{Expected: false},
    58  	}
    59  
    60  	for _, testCase := range testCases {
    61  		assert.Equal(testCase.Expected, env.IsDev(testCase.Input), fmt.Sprintf("failed for: %s", testCase.Input))
    62  	}
    63  }
    64  
    65  func TestIsDevTest(t *testing.T) {
    66  	assert := assert.New(t)
    67  
    68  	testCases := []struct {
    69  		Input    string
    70  		Expected bool
    71  	}{
    72  		{Input: env.ServiceEnvDev, Expected: true},
    73  		{Input: env.ServiceEnvCI, Expected: false},
    74  		{Input: env.ServiceEnvTest, Expected: true},
    75  		{Input: env.ServiceEnvSandbox, Expected: false},
    76  		{Input: env.ServiceEnvPreprod, Expected: false},
    77  		{Input: env.ServiceEnvBeta, Expected: false},
    78  		{Input: env.ServiceEnvProd, Expected: false},
    79  		{Input: uuid.V4().String(), Expected: false},
    80  		{Expected: false},
    81  	}
    82  
    83  	for _, testCase := range testCases {
    84  		assert.Equal(testCase.Expected, env.IsDevTest(testCase.Input), fmt.Sprintf("failed for: %s", testCase.Input))
    85  	}
    86  }