Skip to content

Commit

Permalink
supportedTimeZones: add unit test for String()
Browse files Browse the repository at this point in the history
  • Loading branch information
TerraTalpi committed Aug 30, 2021
1 parent bd19e9c commit afb3516
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions supportedTimeZones_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package msgraph

import (
"math/rand"
"testing"
)

func Test_supportedTimeZones_GetTimeZoneByAlias(t *testing.T) {
testuser := GetTestUser(t)
timezones, _ := testuser.getTimeZoneChoices(compileGetQueryOptions(nil))

randomTimezone := timezones.Value[rand.Intn(len(timezones.Value))]
_, err := timezones.GetTimeZoneByAlias(randomTimezone.Alias)
if err != nil {
t.Errorf("Cannot get timeZone with Alias %v, err: %v", randomTimezone.Alias, err)
}
_, err = timezones.GetTimeZoneByAlias("This is a non existing timezone")
if err == nil {
t.Errorf("Tried to get a non existing timezone, expected an error, but got nil")
}
}

func Test_supportedTimeZones_GetTimeZoneByDisplayName(t *testing.T) {
testuser := GetTestUser(t)
timezones, _ := testuser.getTimeZoneChoices(compileGetQueryOptions(nil))

randomTimezone := timezones.Value[rand.Intn(len(timezones.Value))]
_, err := timezones.GetTimeZoneByDisplayName(randomTimezone.DisplayName)
if err != nil {
t.Errorf("Cannot get timeZone with DisplayName %v, err: %v", randomTimezone.DisplayName, err)
}
_, err = timezones.GetTimeZoneByDisplayName("This is a non existing timezone")
if err == nil {
t.Errorf("Tried to get a non existing timezone, expected an error, but got nil")
}
}

0 comments on commit afb3516

Please sign in to comment.