// TestEnvUint64 calls EnvUint64 with custom env variables.
TestEnvUint64 calls EnvUint64 with custom env variables.
// TestEnvUint64 calls EnvUint64 with custom env variables .
func TestEnvUint64(t *testing.T) {
	t.Parallel()
	cleanEnvVars()
	data := []EnvTestData{
		{
			ServerID:  "",
			ProcessID: "",
			IsError:   true,
		},
		{
			ServerID:  "0",
			ProcessID: "0",
			IsError:   false,
		},
		{
			ServerID:  "-1",
			ProcessID: "-1",
			IsError:   true,
		},
		{
			ServerID:  " ",
			ProcessID: " ",
			IsError:   true,
		},
		{
			ServerID:  "100_000",
			ProcessID: "100_000",
			IsError:   true,
		},
		{
			ServerID:  "1",
			ProcessID: "1",
			IsError:   false,
		},
		{
			ServerID:  "100",
			ProcessID: "100",
			IsError:   false,
		},
	}
	for _, v := range data {
		err := os.Setenv(serverIDKey, v.ServerID)
		if err != nil {
			log.Fatalln("failed to set env", serverIDKey, "to", v.ServerID)
		}
		err = os.Setenv(processIDKey, v.ProcessID)
		if err != nil {
			log.Fatalln("failed to set env", processIDKey, "to", v.ProcessID)
		}
		id, err := EnvUint64(&DefaultUint64Config)
		if err == nil && v.IsError {
			t.Error("expected error found none.",
				"ServerID:", v.ServerID,
				"ProcessID:", v.ProcessID,
				"generated ID:", id,
			)
		}
		if err != nil && !v.IsError {
			t.Error("expected no error, found one, error:", err)
		}
	}
}
func TestEnvUint64 ( t * testing . T ) { t . Parallel ( ) cleanEnvVars ( ) data := [ ] EnvTestData { { ServerID : " " , ProcessID : " " , IsError : true , } , { ServerID : " " , ProcessID : " " , IsError : false , } , { ServerID : " " , ProcessID : " " , IsError : true , } , { ServerID : " " , ProcessID : " " , IsError : true , } , { ServerID : " " , ProcessID : " " , IsError : true , } , { ServerID : " " , ProcessID : " " , IsError : false , } , { ServerID : " " , ProcessID : " " , IsError : false , } , } for _ , v := range data { err := os . Setenv ( serverIDKey , v . ServerID ) if err != nil { log . Fatalln ( " " , serverIDKey , " " , v . ServerID ) } err = os . Setenv ( processIDKey , v . ProcessID ) if err != nil { log . Fatalln ( " " , processIDKey , " " , v . ProcessID ) } id , err := EnvUint64 ( & DefaultUint64Config ) if err == nil && v . IsError { t . Error ( " " , " " , v . ServerID , " " , v . ProcessID , " " , id , ) } if err != nil && ! v . IsError { t . Error ( " " , err ) } } }
TestEnvUint64 calls EnvUint64 with custom env variables.
TestEnvUint64 calls EnvUint64 with custom env variables .