Skip to content
This repository was archived by the owner on Oct 20, 2021. It is now read-only.

Commit 1960c77

Browse files
author
Jamie Brynes
authored
Add ChosenDeploymentAlphaLocatorFlow tests (#225)
1 parent 5246f58 commit 1960c77

19 files changed

+279
-56
lines changed

.buildkite/premerge.steps.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ common: &common
3535
# These are then relied on to have stable names by other things, so once named, please beware renaming has consequences.
3636

3737
steps:
38+
- label: "test"
39+
command: bash -c ci/test.sh
40+
<<: *common
41+
artifact_paths:
42+
- logs/**/*
43+
3844
- label: "build :android:"
3945
command: bash -c .shared-ci/scripts/build-worker.sh
4046
<<: *common

.buildkite/release-qa.steps.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ common: &common
3535
# These are then relied on to have stable names by other things, so once named, please beware renaming has consequences.
3636

3737
steps:
38+
- label: "test"
39+
command: bash -c ci/test.sh
40+
<<: *common
41+
artifact_paths:
42+
- logs/**/*
43+
3844
- label: "build :android:"
3945
command: bash -c .shared-ci/scripts/build-worker.sh
4046
<<: *common

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
## Unreleased
44

5+
### Breaking Changes
6+
7+
- Moved `ChosenDeploymentAlphaLocatorFlow` and `SessionConnectionFlowInitializer` into the `Fps.Connection` namespace and made them `public`. [#225](https://github.com/spatialos/gdk-for-unity-fps-starter-project/pull/225)
8+
9+
### Internal
10+
11+
- Added tests for the `ChosenDeploymentAlphaLocatorFlow`. [#225](https://github.com/spatialos/gdk-for-unity-fps-starter-project/pull/225)
12+
513
## `0.2.6` - 2019-08-05
614

715
### Breaking Changes
@@ -15,8 +23,8 @@
1523
- Added the `io.improbable.gdk.debug` package as a dependency. [#222](https://github.com/spatialos/gdk-for-unity-fps-starter-project/pull/222)
1624

1725
### Changed
18-
- Upgraded to GDK for Unity version `0.2.6`
1926

27+
- Upgraded to GDK for Unity version `0.2.6`
2028
- The `AdvancedEntityPipeline` now uses the `OwningWorker` component from the PlayerLifecycle feature module [#222](https://github.com/spatialos/gdk-for-unity-fps-starter-project/pull/222)
2129
- Removed the `DISABLE_REACTIVE_COMPONENTS` scripting define as it is no longer used. [#222](https://github.com/spatialos/gdk-for-unity-fps-starter-project/pull/222)
2230

ci/test.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
3+
set -e -u -o pipefail
4+
5+
if [[ -n "${DEBUG-}" ]]; then
6+
set -x
7+
fi
8+
9+
cd "$(dirname "$0")/../"
10+
11+
source .shared-ci/scripts/pinned-tools.sh
12+
13+
PROJECT_DIR="$(pwd)"
14+
mkdir -p "${PROJECT_DIR}/logs/"
15+
16+
EDITMODE_TEST_RESULTS_FILE="${PROJECT_DIR}/logs/editmode-test-results.xml"
17+
18+
echo "--- Testing Unity: Editmode :writing_hand:"
19+
20+
pushd "workers/unity"
21+
dotnet run -p "${PROJECT_DIR}/.shared-ci/tools/RunUnity/RunUnity.csproj" -- \
22+
-batchmode \
23+
-projectPath "${PROJECT_DIR}/workers/unity" \
24+
-runEditorTests \
25+
-logfile "${PROJECT_DIR}/logs/unity-editmode-test-run.log" \
26+
-editorTestsResultFile "${EDITMODE_TEST_RESULTS_FILE}" \
27+
-editorTestsFilter Fps
28+
popd

gdk.pinned

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4a4046374963d9555f1da025568dd01502ab9a12
1+
0674de43bb32efe4abbeaa5a401e3978ea84258d

workers/unity/Assets/Fps/Scripts/SetupLogic/ClientWorkerConnector.cs

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Collections.Generic;
44
using System.Linq;
55
using System.Text;
6+
using Fps.Connection;
67
using Improbable.Gdk.Core;
78
using Improbable.Gdk.GameObjectCreation;
89
using Improbable.Gdk.PlayerLifecycle;
@@ -173,58 +174,4 @@ private void SendRequest()
173174
.RequestPlayerCreation(serializedArgs, onPlayerResponse);
174175
}
175176
}
176-
177-
internal class ChosenDeploymentAlphaLocatorFlow : AlphaLocatorFlow
178-
{
179-
private readonly string targetDeployment;
180-
181-
public ChosenDeploymentAlphaLocatorFlow(string targetDeployment,
182-
IConnectionFlowInitializer<AlphaLocatorFlow> initializer = null) : base(initializer)
183-
{
184-
this.targetDeployment = targetDeployment;
185-
}
186-
187-
protected override string SelectLoginToken(List<LoginTokenDetails> loginTokens)
188-
{
189-
var token = loginTokens.FirstOrDefault(loginToken => loginToken.DeploymentName == targetDeployment);
190-
191-
return token.LoginToken ?? throw new ArgumentException("Was not able to connect to deployment");
192-
}
193-
}
194-
195-
internal class SessionConnectionFlowInitializer : IConnectionFlowInitializer<AlphaLocatorFlow>
196-
{
197-
private IConnectionFlowInitializer<AlphaLocatorFlow> initializer;
198-
199-
public SessionConnectionFlowInitializer(IConnectionFlowInitializer<AlphaLocatorFlow> standaloneInitializer)
200-
{
201-
initializer = standaloneInitializer;
202-
}
203-
204-
public void Initialize(AlphaLocatorFlow flow)
205-
{
206-
if (Application.isEditor)
207-
{
208-
if (PlayerPrefs.HasKey(RuntimeConfigNames.DevAuthTokenKey))
209-
{
210-
flow.DevAuthToken = PlayerPrefs.GetString(RuntimeConfigNames.DevAuthTokenKey);
211-
return;
212-
}
213-
214-
var textAsset = Resources.Load<TextAsset>("DevAuthToken");
215-
216-
if (textAsset == null)
217-
{
218-
throw new MissingReferenceException("Unable to find DevAuthToken.txt in the Resources folder. " +
219-
"You can generate one via SpatialOS > Generate Dev Authentication Token.");
220-
}
221-
222-
flow.DevAuthToken = textAsset.text;
223-
}
224-
else
225-
{
226-
initializer.Initialize(flow);
227-
}
228-
}
229-
}
230177
}

workers/unity/Assets/Fps/Scripts/SetupLogic/Connection.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using Improbable.Gdk.Core;
5+
using Improbable.Worker.CInterop.Alpha;
6+
7+
namespace Fps.Connection
8+
{
9+
public class ChosenDeploymentAlphaLocatorFlow : AlphaLocatorFlow
10+
{
11+
private readonly string targetDeployment;
12+
13+
public ChosenDeploymentAlphaLocatorFlow(string targetDeployment,
14+
IConnectionFlowInitializer<AlphaLocatorFlow> initializer = null) : base(initializer)
15+
{
16+
this.targetDeployment = targetDeployment;
17+
}
18+
19+
protected override string SelectLoginToken(List<LoginTokenDetails> loginTokens)
20+
{
21+
var token = loginTokens.FirstOrDefault(loginToken => loginToken.DeploymentName == targetDeployment);
22+
23+
return token.LoginToken ?? throw new ArgumentException("Was not able to connect to deployment");
24+
}
25+
}
26+
}

workers/unity/Assets/Fps/Scripts/SetupLogic/Connection/ChosenDeploymentAlphaLocatorFlow.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using Improbable.Gdk.Core;
2+
using UnityEngine;
3+
4+
namespace Fps.Connection
5+
{
6+
public class SessionConnectionFlowInitializer : IConnectionFlowInitializer<AlphaLocatorFlow>
7+
{
8+
private readonly IConnectionFlowInitializer<AlphaLocatorFlow> initializer;
9+
10+
public SessionConnectionFlowInitializer(IConnectionFlowInitializer<AlphaLocatorFlow> standaloneInitializer)
11+
{
12+
initializer = standaloneInitializer;
13+
}
14+
15+
public void Initialize(AlphaLocatorFlow flow)
16+
{
17+
if (Application.isEditor)
18+
{
19+
if (PlayerPrefs.HasKey(RuntimeConfigNames.DevAuthTokenKey))
20+
{
21+
flow.DevAuthToken = PlayerPrefs.GetString(RuntimeConfigNames.DevAuthTokenKey);
22+
return;
23+
}
24+
25+
var textAsset = Resources.Load<TextAsset>("DevAuthToken");
26+
27+
if (textAsset == null)
28+
{
29+
throw new MissingReferenceException("Unable to find DevAuthToken.txt in the Resources folder. " +
30+
"You can generate one via SpatialOS > Generate Dev Authentication Token.");
31+
}
32+
33+
flow.DevAuthToken = textAsset.text;
34+
}
35+
else
36+
{
37+
initializer.Initialize(flow);
38+
}
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)