Full Mattermost server source with integrated Community Enterprise features. Includes vendor directory for offline/air-gapped builds. Structure: - enterprise-impl/: Enterprise feature implementations - enterprise-community/: Init files that register implementations - enterprise/: Bridge imports (community_imports.go) - vendor/: All dependencies for offline builds Build (online): go build ./cmd/mattermost Build (offline/air-gapped): go build -mod=vendor ./cmd/mattermost 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
64 lines
1.6 KiB
Go
64 lines
1.6 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package oembed
|
|
|
|
import (
|
|
"slices"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestFindEndpointForURL(t *testing.T) {
|
|
youtubeProvider := providers[slices.IndexFunc(providers, func(provider *ProviderEndpoint) bool {
|
|
return provider.URL == "https://www.youtube.com/oembed"
|
|
})]
|
|
|
|
for _, testCase := range []struct {
|
|
Name string
|
|
Input string
|
|
Expected *ProviderEndpoint
|
|
}{
|
|
{
|
|
Name: "random URL",
|
|
Input: "https://example.com/some/random.url",
|
|
Expected: nil,
|
|
},
|
|
{
|
|
Name: "YouTube home page",
|
|
Input: "https://www.youtube.com",
|
|
Expected: nil,
|
|
},
|
|
{
|
|
Name: "YouTube video",
|
|
Input: "https://www.youtube.com/watch?v=szfZfQFUSnU",
|
|
Expected: youtubeProvider,
|
|
},
|
|
{
|
|
Name: "YouTube video with short link and tracking information",
|
|
Input: "https://youtu.be/Qq3zukqBFqQ?si=iK_TPT20H30mH90G",
|
|
Expected: youtubeProvider,
|
|
},
|
|
{
|
|
Name: "YouTube video with playlist",
|
|
Input: "https://www.youtube.com/watch?v=Qq3zukqBFqQ&list=PL-jqvaPsjQpMqnRgFEw_3fuGQbcVDTpaM",
|
|
Expected: youtubeProvider,
|
|
},
|
|
{
|
|
Name: "YouTube playlist",
|
|
Input: "https://www.youtube.com/playlist?list=PL-jqvaPsjQpMqnRgFEw_3fuGQbcVDTpaM",
|
|
Expected: youtubeProvider,
|
|
},
|
|
{
|
|
Name: "YouTube channel",
|
|
Input: "https://www.youtube.com/@MattermostHQ",
|
|
Expected: nil,
|
|
},
|
|
} {
|
|
t.Run(testCase.Name, func(t *testing.T) {
|
|
assert.Equal(t, testCase.Expected, FindEndpointForURL(testCase.Input))
|
|
})
|
|
}
|
|
}
|