github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/pkg/scanners/azure/functions/utc_now_test.go (about)

     1  package functions
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  	"time"
     7  
     8  	"github.com/stretchr/testify/assert"
     9  )
    10  
    11  func Test_UTCNow(t *testing.T) {
    12  
    13  	tests := []struct {
    14  		name     string
    15  		args     []interface{}
    16  		expected string
    17  	}{
    18  		{
    19  			name: "utc now day",
    20  			args: []interface{}{
    21  				"d",
    22  			},
    23  			expected: fmt.Sprintf("%d", time.Now().UTC().Day()),
    24  		},
    25  		{
    26  			name: "utc now date",
    27  			args: []interface{}{
    28  				"yyyy-M-d",
    29  			},
    30  			expected: fmt.Sprintf("%d-%d-%d", time.Now().UTC().Year(), time.Now().UTC().Month(), time.Now().UTC().Day()),
    31  		},
    32  	}
    33  
    34  	for _, tt := range tests {
    35  		t.Run(tt.name, func(t *testing.T) {
    36  			actual := UTCNow(tt.args...)
    37  			assert.Equal(t, tt.expected, actual)
    38  		})
    39  	}
    40  }