github.com/blend/go-sdk@v1.20220411.3/cron/util_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 cron
     9  
    10  import (
    11  	"testing"
    12  	"time"
    13  
    14  	"github.com/blend/go-sdk/assert"
    15  )
    16  
    17  func Test_IsWeekendDay_IsWeekDay(t *testing.T) {
    18  	t.Parallel()
    19  	its := assert.New(t)
    20  
    21  	for _, wd := range WeekendDays {
    22  		its.True(IsWeekendDay(wd))
    23  		its.False(IsWeekDay(wd))
    24  	}
    25  
    26  	for _, wd := range WeekDays {
    27  		its.False(IsWeekendDay(wd))
    28  		its.True(IsWeekDay(wd))
    29  	}
    30  }
    31  
    32  func Test_MinMax(t *testing.T) {
    33  	t.Parallel()
    34  	its := assert.New(t)
    35  
    36  	a := time.Date(2018, 10, 21, 12, 0, 0, 0, time.UTC)
    37  	b := time.Date(2018, 10, 20, 12, 0, 0, 0, time.UTC)
    38  
    39  	its.True(Min(time.Time{}, time.Time{}).IsZero())
    40  	its.Equal(a, Min(a, time.Time{}))
    41  	its.Equal(b, Min(time.Time{}, b))
    42  	its.Equal(b, Min(a, b))
    43  	its.Equal(b, Min(b, a))
    44  
    45  	its.Equal(a, Max(a, b))
    46  	its.Equal(a, Max(b, a))
    47  }
    48  
    49  func Test_Const(t *testing.T) {
    50  	t.Parallel()
    51  	its := assert.New(t)
    52  
    53  	its.Equal(true, ConstBool(true)())
    54  	its.Equal(false, ConstBool(false)())
    55  
    56  	its.Equal(123, ConstInt(123)())
    57  	its.Equal(6*time.Hour, ConstDuration(6*time.Hour)())
    58  	its.Equal("foo", ConstLabels(map[string]string{
    59  		"bar": "buzz",
    60  		"moo": "foo",
    61  	})()["moo"])
    62  }