Skip to content

Commit

Permalink
Merge pull request #188 from microsoft/chore/guid-tests
Browse files Browse the repository at this point in the history
chore: adds unit test to demonstrate guid normalization
  • Loading branch information
baywet authored Nov 11, 2024
2 parents 23ad3d1 + 214f273 commit 7579d75
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ on:
branches: [ main ]
schedule:
- cron: '40 16 * * 3'
workflow_dispatch:

jobs:
analyze:
Expand Down
39 changes: 32 additions & 7 deletions request_information_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"
"time"

"github.com/google/uuid"
"github.com/microsoft/kiota-abstractions-go/store"

"github.com/microsoft/kiota-abstractions-go/internal"
Expand All @@ -24,6 +25,7 @@ type QueryParameters struct {
Top *int32
Status *internal.PersonStatus `uriparametername:"status"`
Statuses []internal.PersonStatus `uriparametername:"statuses"`
Id *uuid.UUID
}

func TestItAddsStringQueryParameters(t *testing.T) {
Expand Down Expand Up @@ -97,13 +99,36 @@ func TestItSetsTheRawURL(t *testing.T) {
}

type getQueryParameters struct {
Count *bool `uriparametername:"%24count"`
Expand []string `uriparametername:"%24expand"`
Select_escaped []string `uriparametername:"%24select"`
Filter *string `uriparametername:"%24filter"`
Orderby []string `uriparametername:"%24orderby"`
Search *string `uriparametername:"%24search"`
Number []int64 `uriparametername:"%24number"`
Count *bool `uriparametername:"%24count"`
Expand []string `uriparametername:"%24expand"`
Select_escaped []string `uriparametername:"%24select"`
Filter *string `uriparametername:"%24filter"`
Orderby []string `uriparametername:"%24orderby"`
Search *string `uriparametername:"%24search"`
Number []int64 `uriparametername:"%24number"`
Id *uuid.UUID `uriparametername:"id"`
}

func TestItSetsUUIDQueryParameters(t *testing.T) {
requestInformation := NewRequestInformation()
requestInformation.UrlTemplate = "http://localhost/users{?id}"
value := uuid.MustParse("95E943B8-52D5-4228-902D-61D65792CED7")
requestInformation.AddQueryParameters(getQueryParameters{
Id: &value,
})
resultUri, err := requestInformation.GetUri()
assert.Nil(t, err)
assert.Equal(t, "http://localhost/users?id=95e943b8-52d5-4228-902d-61d65792ced7", resultUri.String())
}

func TestItSetsUUIDPathParameters(t *testing.T) {
requestInformation := NewRequestInformation()
requestInformation.UrlTemplate = "http://localhost/users/{id}"
value := uuid.MustParse("95E943B8-52D5-4228-902D-61D65792CED7")
requestInformation.PathParametersAny["id"] = &value
resultUri, err := requestInformation.GetUri()
assert.Nil(t, err)
assert.Equal(t, "http://localhost/users/95e943b8-52d5-4228-902d-61d65792ced7", resultUri.String())
}

func TestItSetsNumberArrayQueryParameters(t *testing.T) {
Expand Down

0 comments on commit 7579d75

Please sign in to comment.