github.com/qiniu/go-sdk/v7@v7.27.0/cdn/anti_leech_test.go (about)

     1  //go:build unit
     2  // +build unit
     3  
     4  package cdn
     5  
     6  import (
     7  	"testing"
     8  )
     9  
    10  func TestCreateTimestampAntiLeech(t *testing.T) {
    11  	type args struct {
    12  		urlStr            string
    13  		encryptKey        string
    14  		durationInSeconds int64
    15  	}
    16  	tests := []struct {
    17  		name    string
    18  		args    args
    19  		wantErr bool
    20  	}{
    21  		{
    22  			name: "antileech_1",
    23  			args: args{
    24  				urlStr:            "http://www.example.com/testfile.jpg",
    25  				encryptKey:        "abc123",
    26  				durationInSeconds: 3600,
    27  			},
    28  			wantErr: false,
    29  		},
    30  	}
    31  	for _, tt := range tests {
    32  		t.Run(tt.name, func(t *testing.T) {
    33  			targetUrl, err := CreateTimestampAntileechURL(tt.args.urlStr, tt.args.encryptKey, tt.args.durationInSeconds)
    34  			if (err != nil) != tt.wantErr {
    35  				t.Errorf("CreateTimestampAntiLeech() error = %v, wantErr %v", err, tt.wantErr)
    36  				return
    37  			}
    38  			t.Log(targetUrl)
    39  		})
    40  	}
    41  }