forked from open-networks/go-msgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
supportedTimeZones: add unit test for String()
- Loading branch information
1 parent
bd19e9c
commit afb3516
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} | ||
} |