2025-01-07 19:38:30 -06:00
|
|
|
// Copyright 2024 The Gitea Authors. All rights reserved.
|
2022-11-27 13:20:29 -05:00
|
|
|
// SPDX-License-Identifier: MIT
|
2019-03-27 17:33:00 +08:00
|
|
|
|
|
|
|
package git
|
|
|
|
|
|
|
|
import (
|
2025-01-07 19:38:30 -06:00
|
|
|
"context"
|
2019-03-27 17:33:00 +08:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2025-01-07 19:38:30 -06:00
|
|
|
func TestCommitSubmoduleLink(t *testing.T) {
|
|
|
|
sf := NewCommitSubmoduleFile("git@github.com:user/repo.git", "aaaa")
|
|
|
|
|
|
|
|
wl := sf.SubmoduleWebLink(context.Background())
|
|
|
|
assert.Equal(t, "https://github.com/user/repo", wl.RepoWebLink)
|
|
|
|
assert.Equal(t, "https://github.com/user/repo/commit/aaaa", wl.CommitWebLink)
|
|
|
|
|
|
|
|
wl = sf.SubmoduleWebLink(context.Background(), "1111")
|
|
|
|
assert.Equal(t, "https://github.com/user/repo", wl.RepoWebLink)
|
|
|
|
assert.Equal(t, "https://github.com/user/repo/commit/1111", wl.CommitWebLink)
|
|
|
|
|
|
|
|
wl = sf.SubmoduleWebLink(context.Background(), "1111", "2222")
|
|
|
|
assert.Equal(t, "https://github.com/user/repo", wl.RepoWebLink)
|
|
|
|
assert.Equal(t, "https://github.com/user/repo/compare/1111...2222", wl.CommitWebLink)
|
|
|
|
|
|
|
|
wl = (*CommitSubmoduleFile)(nil).SubmoduleWebLink(context.Background())
|
|
|
|
assert.Nil(t, wl)
|
2019-03-27 17:33:00 +08:00
|
|
|
}
|