Преглед изворни кода

Improve build script

master
Savorboard пре 5 година
родитељ
комит
1c43afb00e
3 измењених фајлова са 12 додато и 24 уклоњено
  1. +4
    -10
      .travis.yml
  2. +1
    -1
      appveyor.yml
  3. +7
    -13
      test/DotNetCore.CAP.MySql.Test/ConnectionUtil.cs

+ 4
- 10
.travis.yml Прегледај датотеку

@@ -4,17 +4,11 @@ dist: xenial
solution: CAP.sln
dotnet: 3.1.100
mono: none
env:
- Cap_MySql_ConnectionString="Server=127.0.0.1;Database=cap_test;Uid=root;Pwd=;Allow User Variables=True;SslMode=none"

#matrix:
# include:
# - dotnet: 2.2
# - os: linux
# dist: trusty # Ubuntu 14.04
# sudo: required
# - os: osx
# osx_image: xcode8.3 # macOS 10.12
# Run the build script
services:
- mysql

script:
- export PATH="$PATH:$HOME/.dotnet/tools"


+ 1
- 1
appveyor.yml Прегледај датотеку

@@ -3,7 +3,7 @@ os: Visual Studio 2019
environment:
BUILDING_ON_PLATFORM: win
BuildEnvironment: appveyor
Cap_MySql_ConnectionStringTemplate: Server=localhost;Database={0};Uid=root;Pwd=Password12!;Allow User Variables=True;SslMode=none
Cap_MySql_ConnectionString: Server=localhost;Database=cap_test;Uid=root;Pwd=Password12!;Allow User Variables=True;SslMode=none
services:
- mysql
before_build:


+ 7
- 13
test/DotNetCore.CAP.MySql.Test/ConnectionUtil.cs Прегледај датотеку

@@ -5,35 +5,29 @@ namespace DotNetCore.CAP.MySql.Test
{
public static class ConnectionUtil
{
private const string DatabaseVariable = "Cap_MySql_DatabaseName";
private const string ConnectionStringTemplateVariable = "Cap_MySql_ConnectionStringTemplate";
private const string ConnectionStringTemplateVariable = "Cap_MySql_ConnectionString";

private const string MasterDatabaseName = "information_schema";
private const string DefaultDatabaseName = @"DotNetCore.CAP.MySql.Test";
private const string DefaultDatabaseName = "cap_test";

private const string DefaultConnectionStringTemplate =
@"Server=localhost;Database={0};Uid=root;Pwd=123123;Allow User Variables=True;SslMode=none;";
private const string DefaultConnectionString =
@"Server=localhost;Database=cap_test;Uid=root;Pwd=123123;Allow User Variables=True;SslMode=none;";

public static string GetDatabaseName()
{
return Environment.GetEnvironmentVariable(DatabaseVariable) ?? DefaultDatabaseName;
return DefaultDatabaseName;
}

public static string GetMasterConnectionString()
{
return string.Format(GetConnectionStringTemplate(), MasterDatabaseName);
return GetConnectionString().Replace(DefaultDatabaseName, MasterDatabaseName);
}

public static string GetConnectionString()
{
return string.Format(GetConnectionStringTemplate(), GetDatabaseName());
}

private static string GetConnectionStringTemplate()
{
return
Environment.GetEnvironmentVariable(ConnectionStringTemplateVariable) ??
DefaultConnectionStringTemplate;
DefaultConnectionString;
}

public static MySqlConnection CreateConnection(string connectionString = null)


Loading…
Откажи
Сачувај