snapshot of https://github.com/pion/webrtc.git (main, 2026-09-15; blobs > 131072B omitted)
Some checks failed
REUSE Compliance Check / lint (push) Failing after 0s
Browser E2E / Test (push) Failing after 3s
Test / test (1.24) (push) Failing after 0s
Test / test-i386 (1.25) (push) Failing after 0s
Test / test-i386 (1.24) (push) Failing after 0s
Test / test-windows (1.25) (push) Failing after 0s
Test / test-windows (1.24) (push) Failing after 0s
Test / test (1.25) (push) Failing after 0s
Examples Tests / Test (push) Failing after 3s
Test / test-macos (1.25) (push) Failing after 0s
Test / test-macos (1.24) (push) Failing after 0s
Go mod tidy / tidy (push) Failing after 0s
Test / test-wasm (push) Failing after 0s
CodeQL / analyze (push) Failing after 1s
Fuzz / fuzz (push) Failing after 0s
Some checks failed
REUSE Compliance Check / lint (push) Failing after 0s
Browser E2E / Test (push) Failing after 3s
Test / test (1.24) (push) Failing after 0s
Test / test-i386 (1.25) (push) Failing after 0s
Test / test-i386 (1.24) (push) Failing after 0s
Test / test-windows (1.25) (push) Failing after 0s
Test / test-windows (1.24) (push) Failing after 0s
Test / test (1.25) (push) Failing after 0s
Examples Tests / Test (push) Failing after 3s
Test / test-macos (1.25) (push) Failing after 0s
Test / test-macos (1.24) (push) Failing after 0s
Go mod tidy / tidy (push) Failing after 0s
Test / test-wasm (push) Failing after 0s
CodeQL / analyze (push) Failing after 1s
Fuzz / fuzz (push) Failing after 0s
This commit is contained in:
105
icecredentialtype_test.go
Normal file
105
icecredentialtype_test.go
Normal file
@@ -0,0 +1,105 @@
|
||||
// SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package webrtc
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestNewICECredentialType(t *testing.T) {
|
||||
testCases := []struct {
|
||||
credentialTypeString string
|
||||
expectedCredentialType ICECredentialType
|
||||
}{
|
||||
{"password", ICECredentialTypePassword},
|
||||
{"oauth", ICECredentialTypeOauth},
|
||||
}
|
||||
|
||||
for i, testCase := range testCases {
|
||||
tpe, err := newICECredentialType(testCase.credentialTypeString)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t,
|
||||
testCase.expectedCredentialType, tpe,
|
||||
"testCase: %d %v", i, testCase,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func TestICECredentialType_String(t *testing.T) {
|
||||
testCases := []struct {
|
||||
credentialType ICECredentialType
|
||||
expectedString string
|
||||
}{
|
||||
{ICECredentialTypePassword, "password"},
|
||||
{ICECredentialTypeOauth, "oauth"},
|
||||
}
|
||||
|
||||
for i, testCase := range testCases {
|
||||
assert.Equal(t,
|
||||
testCase.expectedString,
|
||||
testCase.credentialType.String(),
|
||||
"testCase: %d %v", i, testCase,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func TestICECredentialType_new(t *testing.T) {
|
||||
testCases := []struct {
|
||||
credentialType ICECredentialType
|
||||
expectedString string
|
||||
}{
|
||||
{ICECredentialTypePassword, "password"},
|
||||
{ICECredentialTypeOauth, "oauth"},
|
||||
}
|
||||
|
||||
for i, testCase := range testCases {
|
||||
tpe, err := newICECredentialType(testCase.expectedString)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t,
|
||||
tpe, testCase.credentialType,
|
||||
"testCase: %d %v", i, testCase,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func TestICECredentialType_Json(t *testing.T) {
|
||||
testCases := []struct {
|
||||
credentialType ICECredentialType
|
||||
jsonRepresentation []byte
|
||||
}{
|
||||
{ICECredentialTypePassword, []byte("\"password\"")},
|
||||
{ICECredentialTypeOauth, []byte("\"oauth\"")},
|
||||
}
|
||||
|
||||
for i, testCase := range testCases {
|
||||
m, err := json.Marshal(testCase.credentialType)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t,
|
||||
testCase.jsonRepresentation,
|
||||
m,
|
||||
"Marshal testCase: %d %v", i, testCase,
|
||||
)
|
||||
var ct ICECredentialType
|
||||
err = json.Unmarshal(testCase.jsonRepresentation, &ct)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t,
|
||||
testCase.credentialType,
|
||||
ct,
|
||||
"Unmarshal testCase: %d %v", i, testCase,
|
||||
)
|
||||
}
|
||||
|
||||
{
|
||||
ct := ICECredentialType(1000)
|
||||
err := json.Unmarshal([]byte("\"invalid\""), &ct)
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, ct, ICECredentialType(1000))
|
||||
err = json.Unmarshal([]byte("\"invalid"), &ct)
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, ct, ICECredentialType(1000))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user