package utils

import (
    "os"
    "reflect"
	"testing"
)

func testType[T any]( t *testing.T, name string, fallback T ) T {
    got := TryGetEnv( "ABC", fallback )
    a := reflect.TypeOf( got ).Kind()
    b := reflect.TypeOf( fallback ).Kind()
    if a != b {
        t.Errorf( "%s is not of type %s", any( got ), b )
    }
    return got
}

func TestAll(t *testing.T) {
    testType( t, "ABC", "Test" )
    testType( t, "ABC", 11 )

    os.Setenv( "ABC", "22" )
    got := testType( t, "ABC", 11 )
    if got != 22 {
        t.Errorf( "Expected 22, got %d", got )
    }
}

