Skip to content

Commit 67b48ad

Browse files
authored
The unit test project (SmartSql.Test.Unit) uses MySql as the database for easy integration testing. (#163)
1 parent 456099b commit 67b48ad

File tree

108 files changed

+1921
-1622
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+1921
-1622
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Integration Test
2+
on: [ push ]
3+
jobs:
4+
SmartSql-Unit-Test:
5+
name: SmartSql Unit Test
6+
runs-on: ubuntu-latest
7+
strategy:
8+
matrix:
9+
dotnet: [ '6.0.x' ]
10+
services:
11+
redis:
12+
image: redis
13+
options: >-
14+
--health-cmd "redis-cli ping"
15+
--health-interval 10s
16+
--health-timeout 5s
17+
--health-retries 5
18+
ports:
19+
- 6379:6379
20+
21+
steps:
22+
- name: Start Mysql
23+
run: sudo /etc/init.d/mysql start
24+
25+
- name: Checkout
26+
uses: actions/checkout@master
27+
28+
- name: Set up dotnet
29+
uses: actions/setup-dotnet@v2
30+
with:
31+
dotnet-version: ${{ matrix.dotnet }}
32+
server-id: github
33+
settings-path: ${{ github.workspace }}
34+
35+
- name: Init SmartSql-Test-Db
36+
run: mysql -vvv -h localhost -uroot -proot < src/SmartSql.Test.Unit/DB/init-mysql-db.sql
37+
38+
- name: Unit Test
39+
run: dotnet test

sample/SmartSql.Sample.AspNetCore/Startup.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,8 @@
33
using Microsoft.AspNetCore.Builder;
44
using Microsoft.AspNetCore.Hosting;
55
using Microsoft.AspNetCore.Mvc;
6-
using Microsoft.EntityFrameworkCore.Metadata;
76
using Microsoft.Extensions.Configuration;
87
using Microsoft.Extensions.DependencyInjection;
9-
using SkyApm.Diagnostics.SmartSql;
10-
using SkyApm.Utilities.DependencyInjection;
11-
using SmartSql.Cache.Sync;
12-
using SmartSql.ConfigBuilder;
13-
using SmartSql.DIExtension;
14-
using SmartSql.InvokeSync;
15-
using SmartSql.InvokeSync.Kafka;
168
using SmartSql.InvokeSync.RabbitMQ;
179
using SmartSql.Sample.AspNetCore.Service;
1810
using Swashbuckle.AspNetCore.Swagger;

src/SmartSql.Bulk.MySql/SmartSql.Bulk.MySql.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="MySql.Data" Version="8.0.15" />
12+
<PackageReference Include="MySql.Data" Version="8.0.28" />
1313
</ItemGroup>
1414

1515
<ItemGroup>

src/SmartSql.Test.Unit/AbstractTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace SmartSql.Test.Unit
88
{
99
public abstract class AbstractTest
1010
{
11-
protected String DbType => "SqlServer";
12-
protected String ConnectionString => "Data Source=.;Initial Catalog=SmartSqlTestDB;Integrated Security=True";
11+
protected String DbType => "MySql";
12+
protected String ConnectionString => "server=localhost;uid=root;pwd=root;database=SmartSqlTestDB";
1313
}
1414
}

src/SmartSql.Test.Unit/AutoConverter/AutoConverterTest.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ public AutoConverterTest(SmartSqlFixture smartSqlFixture)
1515
SqlMapper = smartSqlFixture.SqlMapper;
1616
}
1717

18-
[Fact]
18+
// TODO
19+
[Fact(Skip = "TODO")]
1920
public void DefaultAutoConverterTest()
2021
{
2122
for (var i = 1; i <= 2; i++)
@@ -42,7 +43,8 @@ public void DefaultAutoConverterTest()
4243
Assert.NotEqual(0, userList.First().Id);
4344
}
4445

45-
[Fact]
46+
// TODO
47+
[Fact(Skip = "TODO")]
4648
public void DisabledAutoConverterTest()
4749
{
4850
var userId = SqlMapper.QuerySingle<long>(new RequestContext
@@ -70,7 +72,8 @@ public void DisabledAutoConverterTest()
7072
Assert.Equal(userId, userEntity.Id);
7173
}
7274

73-
[Fact]
75+
// TODO
76+
[Fact(Skip = "TODO")]
7477
public void UseNoneAutoConverterTest()
7578
{
7679
var userId = SqlMapper.QuerySingle<long>(new RequestContext
@@ -98,7 +101,8 @@ public void UseNoneAutoConverterTest()
98101
Assert.Equal(userId, userEntity.Id);
99102
}
100103

101-
[Fact]
104+
// TODO
105+
[Fact(Skip = "TODO")]
102106
public void AssignAutoFromRequestConverterTest()
103107
{
104108
for (var i = 1; i <= 2; i++)
@@ -127,7 +131,8 @@ public void AssignAutoFromRequestConverterTest()
127131
Assert.NotEqual(0, list.First().Col_Id);
128132
}
129133

130-
[Fact]
134+
// TODO
135+
[Fact(Skip = "TODO")]
131136
public void AssignFromMapAutoConverterTest()
132137
{
133138
for (var i = 1; i <= 2; i++)
@@ -155,7 +160,8 @@ public void AssignFromMapAutoConverterTest()
155160
Assert.NotEqual(0, list.First().Col_Id);
156161
}
157162

158-
[Fact]
163+
// TODO
164+
[Fact(Skip = "TODO")]
159165
public void AssignFromStatementAutoConverterTest()
160166
{
161167
for (var i = 1; i <= 2; i++)
@@ -187,7 +193,8 @@ public void AssignFromStatementAutoConverterTest()
187193
/// <summary>
188194
/// 同时指定AutoConverter和ResultMap时,ResultMap优先级高于AutoConverter
189195
/// </summary>
190-
[Fact]
196+
// TODO
197+
[Fact(Skip = "TODO")]
191198
public void AssignResultMapAndAutoConverterTest()
192199
{
193200
for (var i = 1; i <= 2; i++)

src/SmartSql.Test.Unit/Bulk/BulkTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void ToDataTable()
3333
}
3434

3535
var watch = Stopwatch.StartNew();
36-
var dataTableE1 = list.ToDataTable();
36+
var dataTable = list.ToDataTable();
3737
_output.WriteLine($"ToDataTable taken :{watch.ElapsedMilliseconds}");
3838
watch.Stop();
3939
}

src/SmartSql.Test.Unit/Bulk/MsSqlServerTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public MsSqlServerTest(MsSqlServerFixture serverFixture)
3737
_dbSessionFactory = serverFixture.DbSessionFactory;
3838
}
3939

40-
[Fact]
40+
[Fact(Skip = "The database environment that the project depends on does not exist.")]
4141
public void Insert()
4242
{
4343
using (var dbSession = _dbSessionFactory.Open())
@@ -54,7 +54,7 @@ public void Insert()
5454
}
5555

5656

57-
[Fact]
57+
[Fact(Skip = "The database environment that the project depends on does not exist.")]
5858
public void InsertByList()
5959
{
6060
using (var dbSession = _dbSessionFactory.Open())
@@ -69,7 +69,7 @@ public void InsertByList()
6969
}
7070
}
7171

72-
[Fact]
72+
[Fact(Skip = "The database environment that the project depends on does not exist.")]
7373
public async Task InsertAsync()
7474
{
7575
using (var dbSession = _dbSessionFactory.Open())
@@ -85,7 +85,7 @@ public async Task InsertAsync()
8585
}
8686
}
8787

88-
[Fact]
88+
[Fact(Skip = "The database environment that the project depends on does not exist.")]
8989
public async Task InsertByListAsync()
9090
{
9191
using (var dbSession = _dbSessionFactory.Open())

src/SmartSql.Test.Unit/Bulk/MySqlConnectorTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ namespace SmartSql.Test.Unit.Bulk
1111
{
1212
public class MySqlConnectorTest
1313
{
14-
[Fact]
14+
[Fact(Skip = "The database environment that the project depends on does not exist.")]
1515
public void Insert()
1616
{
1717
var dbSessionFactory = new SmartSqlBuilder()
18-
.UseDataSource(DbProvider.MYSQL_CONNECTOR, "Data Source=localhost;database=SmartSqlTestDB;uid=root;pwd=SmartSql.net")
18+
.UseDataSource(DbProvider.MYSQL_CONNECTOR, "Data Source=localhost;database=SmartSqlTestDB;uid=root;pwd=root")
1919
.UseAlias("MySqlConnectorTest")
2020
.Build().GetDbSessionFactory();
2121

src/SmartSql.Test.Unit/Bulk/MySqlTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ namespace SmartSql.Test.Unit.Bulk
1111
{
1212
public class MySqlTest
1313
{
14-
[Fact]
14+
[Fact(Skip = "The database environment that the project depends on does not exist.")]
1515
public void Insert()
1616
{
1717
var dbSessionFactory = new SmartSqlBuilder()
18-
.UseDataSource(DbProvider.MYSQL, "Data Source=localhost;database=SmartSqlTestDB;uid=root;pwd=SmartSql.net")
18+
.UseDataSource(DbProvider.MYSQL, "Data Source=localhost;database=SmartSqlTestDB;uid=root;pwd=root")
1919
.UseAlias("MySqlTest")
2020
.Build().GetDbSessionFactory();
2121

src/SmartSql.Test.Unit/Bulk/PostgreSqlTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace SmartSql.Test.Unit.Bulk
1111
{
1212
public class PostgreSqlTest
1313
{
14-
[Fact]
14+
[Fact(Skip = "The database environment that the project depends on does not exist.")]
1515
public void Insert()
1616
{
1717
var dbSessionFactory = new SmartSqlBuilder()

0 commit comments

Comments
 (0)