package obs

import (
	"context"
	"testing"

	. "github.com/smartystreets/goconvey/convey"
	clitypes "gitlink.org.cn/cloudream/jcs-pub/client/types"
	"gitlink.org.cn/cloudream/jcs-pub/common/pkgs/storage/types"
	cortypes "gitlink.org.cn/cloudream/jcs-pub/coordinator/types"
)

func Test_S2S(t *testing.T) {
	Convey("OBS", t, func() {
		s2s := S2STransfer{
			cred: &cortypes.OBSCred{
				Region:    "cn-north-4",
				Endpoint:  "obs.cn-north-4.myhuaweicloud.com",
				AK:        "",
				SK:        "",
				Bucket:    "pcm3-bucket3",
				ProjectID: "",
			},
			feat: &cortypes.S2STransferFeature{
				TempDir: "s2s",
			},
		}

		newPath, err := s2s.Transfer(context.TODO(), &clitypes.UserSpaceDetail{
			UserSpace: clitypes.UserSpace{
				Credential: cortypes.OBSCred{
					Region:    "cn-north-4",
					Endpoint:  "obs.cn-north-4.myhuaweicloud.com",
					AK:        "",
					SK:        "",
					Bucket:    "pcm2-bucket2",
					ProjectID: "",
				},
			},
			Storage: cortypes.Storage{
				Type: &cortypes.OBSType{},
			},
		}, "test_data/test03.txt", types.S2SOption{})
		defer s2s.Abort()

		So(err, ShouldEqual, nil)
		t.Logf("newPath: %s", newPath)
	})
}
