freeleaps-ops/operators/freeleaps-gitops-initializer/internal/repo/plugins/azure/azure_test.go
zhenyus 0e256f8708 chore(git): code staging
Signed-off-by: zhenyus <zhenyus@mathmast.com>
2025-02-17 14:02:49 +08:00

42 lines
1.1 KiB
Go

package azure_test
import (
"context"
"testing"
"freeleaps.com/gitops/initializer/internal/repo"
)
func TestApplyChanges(t *testing.T) {
mgr, ok := repo.GetPlugin("azure-devops")
if !ok {
t.Fatal("plugin not found")
}
pluginConfig := repo.NewPluginConfig()
// pluginConfig.Set("pat", "3E9J1v0si6HRvyc1RSRgT791W9ZvMi4kBmrznfcIXB8mq6Trj9VkJQQJ99BBACAAAAArj0WRAAASAZDO32n4")
pluginConfig.Set("pat", "6MM9azUlikBWsFDqnCpbmDaUrdHz3Cufer9KwWFl67ohoWVrVJ8DJQQJ99BBACAAAAArj0WRAAASAZDOj9V2")
pluginConfig.Set("organizationUrl", "https://dev.azure.com/zhenyus")
err := mgr.Initialize(context.Background(),
repo.WithProject("gitops-repo"),
repo.WithName("gitops-repo"),
repo.WithBranch("master"),
repo.WithAuthor("gitops-bot", "zhenyus@mathmast.com"),
repo.WithPluginConfig(pluginConfig))
if err != nil {
t.Fatal(err)
}
err = mgr.ApplyChanges(context.Background(), []repo.ChangeRequest{
{
Path: "test.txt",
Content: []byte("hello from operator"),
Operation: repo.OpCreate,
},
}, "chore(test): test commit from operator")
if err != nil {
t.Fatal(err)
}
}