A tool to migrate GitHub Repositories to Gitea including all issues
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
gitea-github-migrator/migrations/issue_test.go

49 lines
1.4 KiB

package migrations
import (
"testing"
"code.gitea.io/sdk/gitea"
"github.com/google/go-github/github"
"github.com/stretchr/testify/assert"
)
func Test_githubStateToGiteaState(t *testing.T) {
open := "open"
all := "all"
closed := "closed"
tests := map[*string]string{&all: "open", &open: "open", &closed: "closed"}
for input, exceptedResult := range tests {
actualResult := githubStateToGiteaState(input)
assert.NotNil(t, actualResult)
assert.NotEmpty(t, *actualResult)
assert.Equal(t, exceptedResult, *actualResult)
}
nilInput := "teoafweogwoe"
assert.Nil(t, githubStateToGiteaState(&nilInput))
}
func TestMigratory_Label(t *testing.T) {
res, err := DemoMigratory.Label(&github.Label{
Name: github.String("testlabel"),
Color: github.String("123456"),
})
assert.NoError(t, err)
assert.Equal(t, "123456", res.Color)
assert.Equal(t, "testlabel", res.Name)
}
func TestMigratory_Milestone(t *testing.T) {
res, err := DemoMigratory.Milestone(&github.Milestone{
ID: github.Int64(1),
State: github.String("open"),
Description: github.String("test milestone"),
Title: github.String("TEST"),
DueOn: &demoTime,
})
assert.NoError(t, err)
assert.Equal(t, "TEST", res.Title)
assert.Equal(t, "test milestone", res.Description)
assert.Equal(t, demoTime.Unix(), res.Deadline.Unix())
assert.Equal(t, gitea.StateOpen, res.State)
}