mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-19 09:35:36 -05:00
* Additional SQL Agent config classes (WIP) * Fix build breaks * Clean up job step code * Add VS Code build files * Move changes to other machine * More of the action execution classes * More execution processing refactors * More refactoring * Disable tests for WIP merge * Fix break on Release config * Stage changes to other machine.
88 lines
3.3 KiB
C#
88 lines
3.3 KiB
C#
//
|
|
// Copyright (c) Microsoft. All rights reserved.
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
//
|
|
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.SqlTools.Hosting.Protocol;
|
|
using Microsoft.SqlTools.ServiceLayer.Agent;
|
|
using Microsoft.SqlTools.ServiceLayer.Agent.Contracts;
|
|
using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
|
|
using Microsoft.SqlTools.ServiceLayer.Test.Common;
|
|
using Moq;
|
|
using Xunit;
|
|
|
|
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
|
|
{
|
|
public class AgentJobTests
|
|
{
|
|
/// <summary>
|
|
/// TestHandleCreateAgentJobRequest
|
|
/// </summary>
|
|
//[Fact]
|
|
public async Task TestHandleCreateAgentJobRequest()
|
|
{
|
|
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
|
{
|
|
var createContext = new Mock<RequestContext<CreateAgentJobResult>>();
|
|
var service = new AgentService();
|
|
var connectionResult = await LiveConnectionHelper.InitLiveConnectionInfoAsync("master", queryTempFile.FilePath);
|
|
await service.HandleCreateAgentJobRequest(new CreateAgentJobParams
|
|
{
|
|
OwnerUri = connectionResult.ConnectionInfo.OwnerUri,
|
|
Job = new AgentJobInfo()
|
|
{
|
|
Name = "Test Job",
|
|
Owner = "sa",
|
|
Description = "Test job description",
|
|
CurrentExecutionStatus = 1,
|
|
LastRunOutcome = 1,
|
|
CurrentExecutionStep = "Step 1",
|
|
Enabled = false,
|
|
HasTarget = false,
|
|
HasSchedule = false,
|
|
HasStep = false,
|
|
Runnable = true,
|
|
Category = "Cateory 1",
|
|
CategoryId = 1,
|
|
CategoryType = 1,
|
|
LastRun = "today",
|
|
NextRun = "tomorrow",
|
|
JobId = Guid.NewGuid().ToString()
|
|
}
|
|
}, createContext.Object);
|
|
createContext.VerifyAll();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// TestHandleCreateAgentJobStepRequest
|
|
/// </summary>
|
|
//[Fact]
|
|
public async Task TestHandleCreateAgentJobStepRequest()
|
|
{
|
|
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
|
{
|
|
var createContext = new Mock<RequestContext<CreateAgentJobStepResult>>();
|
|
var service = new AgentService();
|
|
var connectionResult = await LiveConnectionHelper.InitLiveConnectionInfoAsync("master", queryTempFile.FilePath);
|
|
await service.HandleCreateAgentJobStepRequest(new CreateAgentJobStepParams
|
|
{
|
|
OwnerUri = connectionResult.ConnectionInfo.OwnerUri,
|
|
Step = new AgentJobStepInfo()
|
|
{
|
|
// JobId = Guid.NewGuid().ToString(),
|
|
Script = @"c:\xplat\test.sql",
|
|
ScriptName = "Test Script",
|
|
|
|
|
|
}
|
|
}, createContext.Object);
|
|
createContext.VerifyAll();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|