小编dse*_*ple的帖子

触发管道并等待其从另一个管道完成

我有两个不同的项目存储库:我的应用程序存储库和API存储库.我的应用程序与API通信.

我想为我的应用程序设置一些集成和E2E测试.运行这些测试时,应用程序将需要使用最新版本的API项目.

API项目已设置为在触发时进行部署

deploy_integration_tests:
  stage: deploy
  script:
  - echo "deploying..."
  environment:
    name: integration_testing
  only:
    - triggers
Run Code Online (Sandbox Code Playgroud)

我的应用程序有一个集成测试工作设置如下:

integration_test
  stage: integration_test
  script:
    - echo "Building and deploying API..."
    - curl.exe -X POST -F token=<token> -F ref=develop <url_for_api_trigger>
    - echo "Now running the integration test that depends on the API deployment..."
Run Code Online (Sandbox Code Playgroud)

我遇到的问题是触发器只排队API管道(两个项目都使用相同的运行程序)并在API管道实际运行之前继续.

有没有办法在尝试运行集成测试之前等待API管道运行?

我可以这样做:

integration_test_dependency
  stage: integration_test_dependency
  script:
    - echo "Building and deploying API..."
    - curl.exe -X POST -F token=<token> -F ref=develop <url_for_api_trigger>

integration_test
  stage: integration_test
  script:
    - echo "Now running the …
Run Code Online (Sandbox Code Playgroud)

gitlab gitlab-ci

11
推荐指数
3
解决办法
5387
查看次数

如何在使用SqlBulkCopy时检索服务器生成的标识值

我知道我可以通过不指定此处SqlBulkCopyOptions.KeepIdentity提到的标识列来批量插入到我的表中.

我希望能够获得服务器生成的标识值并将它们放在我的数据表中,甚至是列表中.我看到这篇文章,但我希望我的代码是通用的,我的所有表中都没有版本列.任何建议都非常感谢.这是我的代码:

public void BulkInsert(DataTable dataTable, string DestinationTbl, int batchSize)
{
    // Get the DataTable 
    DataTable dtInsertRows = dataTable;

    using (SqlBulkCopy sbc = new SqlBulkCopy(sConnectStr))
    {
        sbc.DestinationTableName = DestinationTbl;

        // Number of records to be processed in one go
        sbc.BatchSize = batchSize;

        // Add your column mappings here
        foreach (DataColumn dCol in dtInsertRows.Columns)
        {
            sbc.ColumnMappings.Add(dCol.ColumnName, dCol.ColumnName);
        }

        // Finally write to server
        sbc.WriteToServer(dtInsertRows);
    }
}
Run Code Online (Sandbox Code Playgroud)

c# sql-server identity sqlbulkcopy

6
推荐指数
1
解决办法
5083
查看次数

指向基类的 gmock 指针没有成员 gmock_

对不起,如果标题不清楚。

我有一个虚拟基类:

class FileSystemInterface {
public:
    virtual ~FileSystemInterface() {};

    virtual void save(std::string file_content) = 0;
};
Run Code Online (Sandbox Code Playgroud)

我的模拟类源自于此:

class MockFile : public FileSystemInterface
{
public:
    MOCK_METHOD1(save, void(std::string));
};
Run Code Online (Sandbox Code Playgroud)

现在我有一个我正在测试的方法,它需要一个唯一的指针FileSystemInterface

void my_method(std::unique_ptr<FileSystemInterface>& interface)
Run Code Online (Sandbox Code Playgroud)

我的测试代码如下:

std::unique_ptr<FileSystemInterface> mockFile(new MockFile);
EXPECT_CALL(*mockFile, save(_));
my_method(mockFile);
Run Code Online (Sandbox Code Playgroud)

问题是EXPECT_CALL给了我一个错误class "FileSystemInterface" has no member "gmock_save"

大概是因为我的模拟是指向基类的指针,但是如果我按如下方式更改我的测试:

std::unique_ptr<MockFile> mockFile(new MockFile);
EXPECT_CALL(*mockFile, save(_));
my_method(mockFile);
Run Code Online (Sandbox Code Playgroud)

然后EXPECT_CALL很好,但现在my_method抱怨:a reference of type "std::unique_ptr<FileSystemInterface, std::default_delete<FileSystemInterface>> &" (not const-qualified) cannot be initialized with a value of type "std::unique_ptr<MockFile, std::default_delete<MockFile>>" …

unit-testing googlemock c++11

4
推荐指数
1
解决办法
6360
查看次数