Skip to content

Commit ae8c596

Browse files
committed
resolve conflict
test ci add test-ci add test-ci update test-ci.yml delete variable localfile test ci test ci test ci test ci test ci test ci test ci test ci test ci update ResumableUploaderTest
1 parent 6a13149 commit ae8c596

File tree

7 files changed

+72
-36
lines changed

7 files changed

+72
-36
lines changed

.github/workflows/test-ci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: CSHARP CI
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- '**.md'
7+
8+
jobs:
9+
build:
10+
strategy:
11+
fail-fast: false
12+
max-parallel: 1
13+
14+
runs-on: windows-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v2
18+
19+
- name: Setup
20+
uses: actions/setup-dotnet@v1
21+
with:
22+
dotnet-version: 2.1.502
23+
24+
- name: Build
25+
run: dotnet build src/Qiniu/Qiniu.csproj
26+
27+
- name: Test
28+
run: dotnet test src/QiniuTests/QiniuTests.csproj
29+
30+
env:
31+
QINIU_ACCESS_KEY: ${{ secrets.QINIU_ACCESS_KEY }}
32+
QINIU_SECRET_KEY: ${{ secrets.QINIU_SECRET_KEY }}
33+
QINIU_TEST_BUCKET: ${{ secrets.QINIU_TEST_BUCKET }}
34+
QINIU_TEST_DOMAIN: ${{ secrets.QINIU_TEST_DOMAIN }}

.travis.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/Qiniu/Storage/ResumableUploader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ private void MakeBlock(object resumeBlockerObj)
391391
using (MemoryStream ms = new MemoryStream(blockBuffer, 0, blockSize))
392392
{
393393
byte[] data = ms.ToArray();
394-
394+
395395
result = httpManager.PostData(url, data, upTokenStr);
396396

397397
if (result.Code == (int)HttpCode.OK)

src/QiniuTests/CDN/CdnManagerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public void GetCdnLogListTest()
253253
{
254254
Mac mac = new Mac(AccessKey, SecretKey);
255255
CdnManager manager = new CdnManager(mac);
256-
string day = "2017-08-10";
256+
string day = "2021-07-12";
257257
string[] domains = new string[] { Domain};
258258
LogListResult ret = manager.GetCdnLogList(domains, day);
259259
if (ret.Code != (int)HttpCode.OK)

src/QiniuTests/Storage/FormUploaderTests.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@ public void UploadFileTest()
1616
Random rand = new Random();
1717
string key = string.Format("UploadFileTest_{0}.dat", rand.Next());
1818

19-
string filePath = LocalFile;
19+
string tempPath = System.IO.Path.GetTempPath();
20+
int rnd = new Random().Next(1, 100000);
21+
string filePath = tempPath + "resumeFile" + rnd.ToString();
22+
char[] testBody = new char[4 * 1024 * 1024];
23+
System.IO.FileStream stream = new System.IO.FileStream(filePath, System.IO.FileMode.Create);
24+
System.IO.StreamWriter sw = new System.IO.StreamWriter(stream, System.Text.Encoding.Default);
25+
sw.Write(testBody);
26+
sw.Close();
27+
stream.Close();
2028

2129
PutPolicy putPolicy = new PutPolicy();
2230
putPolicy.Scope = Bucket + ":" + key;
@@ -32,6 +40,7 @@ public void UploadFileTest()
3240
HttpResult result = target.UploadFile(filePath, key, token, null);
3341
Console.WriteLine("form upload result: " + result.ToString());
3442
Assert.AreEqual((int)HttpCode.OK, result.Code);
43+
System.IO.File.Delete(filePath);
3544
}
3645
}
3746
}

src/QiniuTests/Storage/ResumableUploaderTests.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@ public void UploadFileTest()
1616
Random rand = new Random();
1717
string key = string.Format("UploadFileTest_{0}.dat", rand.Next());
1818

19-
string filePath = LocalFile;
19+
string tempPath = System.IO.Path.GetTempPath();
20+
int rnd = new Random().Next(1, 100000);
21+
string filePath = tempPath + "resumeFile" + rnd.ToString();
22+
char[] testBody = new char[4 * 1024 * 1024];
23+
System.IO.FileStream stream = new System.IO.FileStream(filePath, System.IO.FileMode.Create);
24+
System.IO.StreamWriter sw = new System.IO.StreamWriter(stream, System.Text.Encoding.Default);
25+
sw.Write(testBody);
26+
sw.Close();
27+
stream.Close();
2028

2129
PutPolicy putPolicy = new PutPolicy();
2230
putPolicy.Scope = Bucket + ":" + key;
@@ -33,6 +41,7 @@ public void UploadFileTest()
3341
HttpResult result = target.UploadFile(filePath, key, token, null);
3442
Console.WriteLine("chunk upload result: " + result.ToString());
3543
Assert.AreEqual((int)HttpCode.OK, result.Code);
44+
System.IO.File.Delete(filePath);
3645
}
3746

3847
[Test]
@@ -41,8 +50,16 @@ public void ResumeUploadFileTest()
4150
Mac mac = new Mac(AccessKey, SecretKey);
4251
Random rand = new Random();
4352
string key = string.Format("UploadFileTest_{0}.dat", rand.Next());
44-
45-
string filePath = LocalFile;
53+
54+
string tempPath = System.IO.Path.GetTempPath();
55+
int rnd = new Random().Next(1, 100000);
56+
string filePath = tempPath + "resumeFile" + rnd.ToString();
57+
char[] testBody = new char[4 * 1024 * 1024];
58+
System.IO.FileStream stream = new System.IO.FileStream(filePath, System.IO.FileMode.Create);
59+
System.IO.StreamWriter sw = new System.IO.StreamWriter(stream, System.Text.Encoding.Default);
60+
sw.Write(testBody);
61+
sw.Close();
62+
stream.Close();
4663
System.IO.Stream fs = System.IO.File.OpenRead(filePath);
4764

4865
PutPolicy putPolicy = new PutPolicy();
@@ -65,6 +82,7 @@ public void ResumeUploadFileTest()
6582
HttpResult result = target.UploadStream(fs, key, token, extra);
6683
Console.WriteLine("resume upload: " + result.ToString());
6784
Assert.AreEqual((int)HttpCode.OK, result.Code);
85+
System.IO.File.Delete(filePath);
6886
}
6987
}
7088
}

src/QiniuTests/TestEnv.cs

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,12 @@ public class TestEnv
66
public string SecretKey;
77
public string Bucket;
88
public string Domain;
9-
public string LocalFile;
109

1110
public TestEnv()
1211
{
13-
string isTravisTest = System.Environment.GetEnvironmentVariable("isTravisTest");
14-
if (!string.IsNullOrEmpty(isTravisTest) && isTravisTest.Equals("true"))
15-
{
16-
this.AccessKey = System.Environment.GetEnvironmentVariable("QINIU_ACCESS_KEY");
17-
this.SecretKey = System.Environment.GetEnvironmentVariable("QINIU_SECRET_KEY");
18-
this.Bucket = System.Environment.GetEnvironmentVariable("QINIU_TEST_BUCKET");
19-
this.Domain = System.Environment.GetEnvironmentVariable("QINIU_TEST_DOMAIN");
20-
this.LocalFile = System.Environment.GetEnvironmentVariable("QINIU_LOCAL_FILE");
21-
}
22-
else
23-
{
24-
this.AccessKey = "";
25-
this.SecretKey = "";
26-
this.Bucket = "csharpsdk";
27-
this.Domain = "csharpsdk.qiniudn.com";
28-
this.LocalFile = "E:\\VSProjects\\csharp-sdk\\tools\\files\\test.jpg";
29-
}
30-
}
31-
32-
12+
this.AccessKey = System.Environment.GetEnvironmentVariable("QINIU_ACCESS_KEY");
13+
this.SecretKey = System.Environment.GetEnvironmentVariable("QINIU_SECRET_KEY");
14+
this.Bucket = System.Environment.GetEnvironmentVariable("QINIU_TEST_BUCKET");
15+
this.Domain = System.Environment.GetEnvironmentVariable("QINIU_TEST_DOMAIN"); }
3316
}
34-
}
17+
}

0 commit comments

Comments
 (0)