2024-11-11 16:36:51 +03:00
|
|
|
package microl
|
2024-11-28 16:59:40 +03:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"os"
|
|
|
|
|
"testing"
|
2024-11-29 14:33:29 +03:00
|
|
|
"time"
|
2024-11-28 16:59:40 +03:00
|
|
|
)
|
|
|
|
|
|
2024-11-29 14:33:29 +03:00
|
|
|
func TestSet_FieldFromEnv_String(t *testing.T) {
|
2024-11-28 16:59:40 +03:00
|
|
|
type Struct1 struct {
|
|
|
|
|
TestSet_FieldFromEnv string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Name := "TestSet_FieldFromEnv"
|
|
|
|
|
os.Setenv(Name, Name)
|
|
|
|
|
|
|
|
|
|
Struct := Struct1{}
|
|
|
|
|
Set_FieldFromEnv_String(&Struct, Name, true)
|
|
|
|
|
|
|
|
|
|
if Struct.TestSet_FieldFromEnv != Name {
|
|
|
|
|
t.Error("Set_FieldFromEnv_String() error")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2024-11-29 14:33:29 +03:00
|
|
|
|
|
|
|
|
func TestSet_FieldFromEnv_Int(t *testing.T) {
|
|
|
|
|
type Struct1 struct {
|
|
|
|
|
TestSet_FieldFromEnv int
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Name := "TestSet_FieldFromEnv"
|
|
|
|
|
os.Setenv(Name, "1")
|
|
|
|
|
|
|
|
|
|
Struct := Struct1{}
|
|
|
|
|
Set_FieldFromEnv_Int(&Struct, Name, true)
|
|
|
|
|
|
|
|
|
|
if Struct.TestSet_FieldFromEnv != 1 {
|
|
|
|
|
t.Error("TestSet_FieldFromEnv_Int() error")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestSet_FieldFromEnv_Int64(t *testing.T) {
|
|
|
|
|
type Struct1 struct {
|
|
|
|
|
TestSet_FieldFromEnv int64
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Name := "TestSet_FieldFromEnv"
|
|
|
|
|
os.Setenv(Name, "1")
|
|
|
|
|
|
|
|
|
|
Struct := Struct1{}
|
|
|
|
|
Set_FieldFromEnv_Int64(&Struct, Name, true)
|
|
|
|
|
|
|
|
|
|
if Struct.TestSet_FieldFromEnv != 1 {
|
|
|
|
|
t.Error("TestSet_FieldFromEnv_Int64() error")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
func TestSet_FieldFromEnv_Int32(t *testing.T) {
|
|
|
|
|
type Struct1 struct {
|
|
|
|
|
TestSet_FieldFromEnv int32
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Name := "TestSet_FieldFromEnv"
|
|
|
|
|
os.Setenv(Name, "1")
|
|
|
|
|
|
|
|
|
|
Struct := Struct1{}
|
|
|
|
|
Set_FieldFromEnv_Int32(&Struct, Name, true)
|
|
|
|
|
|
|
|
|
|
if Struct.TestSet_FieldFromEnv != 1 {
|
|
|
|
|
t.Error("TestSet_FieldFromEnv_Int32() error")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestSet_FieldFromEnv_Time(t *testing.T) {
|
|
|
|
|
type Struct1 struct {
|
|
|
|
|
TestSet_FieldFromEnv time.Time
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sTime := "02.01.2000 00:00:00"
|
2025-08-12 13:02:09 +03:00
|
|
|
Time1, err := time.Parse(constants_starter.LayoutDateTimeRus, sTime)
|
2024-11-29 14:33:29 +03:00
|
|
|
if err != nil {
|
|
|
|
|
t.Error("TestSet_FieldFromEnv_Time() error")
|
|
|
|
|
}
|
|
|
|
|
//sTime := Time1.GoString()
|
|
|
|
|
Name := "TestSet_FieldFromEnv"
|
|
|
|
|
os.Setenv(Name, sTime)
|
|
|
|
|
|
|
|
|
|
Struct := Struct1{}
|
|
|
|
|
Set_FieldFromEnv_Time(&Struct, Name, true)
|
|
|
|
|
|
|
|
|
|
if Struct.TestSet_FieldFromEnv != Time1 {
|
|
|
|
|
t.Error("TestSet_FieldFromEnv_Time() error")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestSet_FieldFromEnv_Date(t *testing.T) {
|
|
|
|
|
type Struct1 struct {
|
|
|
|
|
TestSet_FieldFromEnv time.Time
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sTime := "02.01.2000"
|
2025-08-12 13:02:09 +03:00
|
|
|
Time1, err := time.Parse(constants_starter.LayoutDateRus, sTime)
|
2024-11-29 14:33:29 +03:00
|
|
|
if err != nil {
|
|
|
|
|
t.Error("TestSet_FieldFromEnv_Date() error")
|
|
|
|
|
}
|
|
|
|
|
//sTime := Time1.GoString()
|
|
|
|
|
Name := "TestSet_FieldFromEnv"
|
|
|
|
|
os.Setenv(Name, sTime)
|
|
|
|
|
|
|
|
|
|
Struct := Struct1{}
|
|
|
|
|
Set_FieldFromEnv_Date(&Struct, Name, true)
|
|
|
|
|
|
|
|
|
|
if Struct.TestSet_FieldFromEnv != Time1 {
|
|
|
|
|
t.Error("TestSet_FieldFromEnv_Date() error")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2024-12-02 13:58:30 +03:00
|
|
|
|
|
|
|
|
func TestSet_FieldFromEnv_Bool(t *testing.T) {
|
|
|
|
|
type Struct1 struct {
|
|
|
|
|
TestSet_FieldFromEnv bool
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Name := "TestSet_FieldFromEnv"
|
|
|
|
|
os.Setenv(Name, "1")
|
|
|
|
|
|
|
|
|
|
Struct := Struct1{}
|
|
|
|
|
Set_FieldFromEnv_Bool(&Struct, Name, true)
|
|
|
|
|
|
|
|
|
|
if Struct.TestSet_FieldFromEnv != true {
|
|
|
|
|
t.Error("TestSet_FieldFromEnv_Bool() error")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2025-05-15 09:56:56 +03:00
|
|
|
|
|
|
|
|
func TestShowTimePassed_FormatText(t *testing.T) {
|
|
|
|
|
ShowTimePassed_FormatText("start offer Download_and_Save_All(), time passed: %s", time.Now())
|
|
|
|
|
}
|
2025-06-20 09:51:22 +03:00
|
|
|
|
|
|
|
|
func TestShow_Stage(t *testing.T) {
|
|
|
|
|
Show_Stage()
|
|
|
|
|
}
|