github.com/zhongdalu/gf@v1.0.0/g/internal/cmdenv/cmdenv_test.go (about)

     1  // Copyright 2017 gf Author(https://github.com/zhongdalu/gf). All Rights Reserved.
     2  //
     3  // This Source Code Form is subject to the terms of the MIT License.
     4  // If a copy of the MIT was not distributed with this file,
     5  // You can obtain one at https://github.com/zhongdalu/gf.
     6  
     7  // go test *.go -bench=".*" -benchmem
     8  
     9  package cmdenv
    10  
    11  import (
    12  	"os"
    13  	"testing"
    14  
    15  	"github.com/zhongdalu/gf/g/test/gtest"
    16  )
    17  
    18  func Test_Get(t *testing.T) {
    19  	os.Args = []string{"--gf.test.value1=111"}
    20  	os.Setenv("GF_TEST_VALUE1", "222")
    21  	os.Setenv("GF_TEST_VALUE2", "333")
    22  	doInit()
    23  	gtest.Case(t, func() {
    24  		gtest.Assert(Get("gf.test.value1").String(), "111")
    25  		gtest.Assert(Get("gf.test.value2").String(), "333")
    26  		gtest.Assert(Get("gf.test.value3").String(), "")
    27  		gtest.Assert(Get("gf.test.value3", 1).String(), "1")
    28  	})
    29  }