Skip to content

Commit 3053599

Browse files
authored
test(functions): increase code coverage (#647)
1 parent b13788c commit 3053599

File tree

19 files changed

+635
-180
lines changed

19 files changed

+635
-180
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,10 @@ jobs:
3030
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
3131
- name: List available devices
3232
run: xcrun simctl list devices available
33-
- name: Cache derived data
34-
uses: actions/cache@v3
35-
with:
36-
path: |
37-
~/.derivedData
38-
key: |
39-
deriveddata-xcodebuild-${{ matrix.platform }}-${{ matrix.xcode }}-${{ matrix.command }}-${{ hashFiles('**/Sources/**/*.swift', '**/Tests/**/*.swift') }}
40-
restore-keys: |
41-
deriveddata-xcodebuild-${{ matrix.platform }}-${{ matrix.xcode }}-${{ matrix.command }}-
4233
- name: Set IgnoreFileSystemDeviceInodeChanges flag
4334
run: defaults write com.apple.dt.XCBuild IgnoreFileSystemDeviceInodeChanges -bool YES
4435
- name: Update mtime for incremental builds
4536
uses: chetan/git-restore-mtime-action@v2
46-
- run: make dot-env
4737
- name: Debug
4838
run: make XCODEBUILD_ARGUMENT="${{ matrix.command }}" CONFIG=Debug PLATFORM="${{ matrix.platform }}" xcodebuild
4939
- name: Release
@@ -62,7 +52,6 @@ jobs:
6252
github-token: ${{ secrets.GITHUB_TOKEN }}
6353
file: lcov.info
6454

65-
6655
xcodebuild:
6756
name: xcodebuild (15)
6857
runs-on: macos-14
@@ -77,6 +66,7 @@ jobs:
7766
- { xcode: 15.2, platform: TVOS }
7867
- { xcode: 15.2, platform: VISIONOS }
7968
- { xcode: 15.2, platform: WATCHOS }
69+
- { command: test, platform: WATCHOS }
8070
include:
8171
- { command: test, skip_release: 1 }
8272
steps:
@@ -105,7 +95,6 @@ jobs:
10595
run: defaults write com.apple.dt.XCBuild IgnoreFileSystemDeviceInodeChanges -bool YES
10696
- name: Update mtime for incremental builds
10797
uses: chetan/git-restore-mtime-action@v2
108-
- run: make dot-env
10998
- name: Debug
11099
run: make XCODEBUILD_ARGUMENT="${{ matrix.command }}" CONFIG=Debug PLATFORM="${{ matrix.platform }}" xcodebuild
111100
- name: Release
@@ -132,7 +121,6 @@ jobs:
132121
# build-spm-linux-${{ matrix.swift-version }}-${{ hashFiles('**/Sources/**/*.swift', '**/Tests/**/*.swift', '**/Package.resolved') }}
133122
# restore-keys: |
134123
# build-spm-linux-${{ matrix.swift-version }}-
135-
# - run: make dot-env
136124
# - name: Run tests
137125
# run: swift test --skip IntegrationTests
138126

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,5 @@ iOSInjectionProject/
9999
# Environment
100100
.env
101101
Secrets.swift
102-
DotEnv.swift
103102
lcov.info
104103
temp_coverage

.swiftpm/xcode/xcshareddata/xcschemes/Supabase.xcscheme

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,52 @@
9797
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
9898
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
9999
shouldUseLaunchSchemeArgsEnv = "YES"
100-
codeCoverageEnabled = "YES">
100+
codeCoverageEnabled = "YES"
101+
onlyGenerateCoverageForSpecifiedTargets = "YES">
102+
<CodeCoverageTargets>
103+
<BuildableReference
104+
BuildableIdentifier = "primary"
105+
BlueprintIdentifier = "Auth"
106+
BuildableName = "Auth"
107+
BlueprintName = "Auth"
108+
ReferencedContainer = "container:">
109+
</BuildableReference>
110+
<BuildableReference
111+
BuildableIdentifier = "primary"
112+
BlueprintIdentifier = "Functions"
113+
BuildableName = "Functions"
114+
BlueprintName = "Functions"
115+
ReferencedContainer = "container:">
116+
</BuildableReference>
117+
<BuildableReference
118+
BuildableIdentifier = "primary"
119+
BlueprintIdentifier = "PostgREST"
120+
BuildableName = "PostgREST"
121+
BlueprintName = "PostgREST"
122+
ReferencedContainer = "container:">
123+
</BuildableReference>
124+
<BuildableReference
125+
BuildableIdentifier = "primary"
126+
BlueprintIdentifier = "Realtime"
127+
BuildableName = "Realtime"
128+
BlueprintName = "Realtime"
129+
ReferencedContainer = "container:">
130+
</BuildableReference>
131+
<BuildableReference
132+
BuildableIdentifier = "primary"
133+
BlueprintIdentifier = "Storage"
134+
BuildableName = "Storage"
135+
BlueprintName = "Storage"
136+
ReferencedContainer = "container:">
137+
</BuildableReference>
138+
<BuildableReference
139+
BuildableIdentifier = "primary"
140+
BlueprintIdentifier = "Supabase"
141+
BuildableName = "Supabase"
142+
BlueprintName = "Supabase"
143+
ReferencedContainer = "container:">
144+
</BuildableReference>
145+
</CodeCoverageTargets>
101146
<Testables>
102147
<TestableReference
103148
skipped = "NO">

Makefile

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,13 @@ endif
3838

3939
TEST_RUNNER_CI = $(CI)
4040

41-
export SECRETS
42-
define SECRETS
43-
enum DotEnv {
44-
static let SUPABASE_URL = "$(SUPABASE_URL)"
45-
static let SUPABASE_ANON_KEY = "$(SUPABASE_ANON_KEY)"
46-
static let SUPABASE_SERVICE_ROLE_KEY = "$(SUPABASE_SERVICE_ROLE_KEY)"
47-
}
48-
endef
49-
5041
xcodebuild:
5142
$(XCODEBUILD)
5243

53-
load-env:
54-
@. ./scripts/load_env.sh
55-
56-
dot-env:
57-
@echo "$$SECRETS" > Tests/IntegrationTests/DotEnv.swift
58-
59-
test-integration: dot-env
60-
$(MAKE) TEST_PLAN=Integration xcodebuild
44+
test-integration:
45+
cd Tests/IntegrationTests && supabase start && supabase db reset
46+
swift test --filter IntegrationTests
47+
cd Tests/IntegrationTests && supabase stop
6148

6249
build-for-library-evolution:
6350
swift build \
@@ -107,4 +94,4 @@ coverage:
10794

10895
define udid_for
10996
$(shell xcrun simctl list devices available '$(1)' | grep '$(2)' | sort -r | head -1 | awk -F '[()]' '{ print $$(NF-3) }')
110-
endef
97+
endef

Package.resolved

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ let package = Package(
2424
targets: ["Supabase", "Functions", "PostgREST", "Auth", "Realtime", "Storage"]),
2525
],
2626
dependencies: [
27-
.package(url: "https://github.com/apple/swift-http-types.git", from: "1.3.0"),
2827
.package(url: "https://github.com/apple/swift-crypto.git", "1.0.0"..<"4.0.0"),
28+
.package(url: "https://github.com/apple/swift-http-types.git", from: "1.3.0"),
29+
.package(url: "https://github.com/pointfreeco/swift-clocks", from: "1.0.0"),
2930
.package(url: "https://github.com/pointfreeco/swift-concurrency-extras", from: "1.1.0"),
3031
.package(url: "https://github.com/pointfreeco/swift-custom-dump", from: "1.3.2"),
31-
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.17.2"),
32+
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.17.0"),
3233
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.2.2"),
33-
.package(url: "https://github.com/pointfreeco/swift-clocks", from: "1.0.0"),
34+
.package(url: "https://github.com/WeTransfer/Mocker", from: "3.0.0"),
3435
],
3536
targets: [
3637
.target(
@@ -39,6 +40,7 @@ let package = Package(
3940
.product(name: "ConcurrencyExtras", package: "swift-concurrency-extras"),
4041
.product(name: "HTTPTypes", package: "swift-http-types"),
4142
.product(name: "Clocks", package: "swift-clocks"),
43+
.product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay"),
4244
]
4345
),
4446
.testTarget(
@@ -60,11 +62,11 @@ let package = Package(
6062
name: "AuthTests",
6163
dependencies: [
6264
.product(name: "CustomDump", package: "swift-custom-dump"),
63-
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
6465
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
66+
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
6567
.product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay"),
66-
"Helpers",
6768
"Auth",
69+
"Helpers",
6870
"TestHelpers",
6971
],
7072
exclude: [
@@ -82,12 +84,13 @@ let package = Package(
8284
name: "FunctionsTests",
8385
dependencies: [
8486
.product(name: "ConcurrencyExtras", package: "swift-concurrency-extras"),
87+
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
8588
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
8689
.product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay"),
8790
"Functions",
91+
"Mocker",
8892
"TestHelpers",
89-
],
90-
exclude: ["__Snapshots__"]
93+
]
9194
),
9295
.testTarget(
9396
name: "IntegrationTests",
@@ -99,7 +102,10 @@ let package = Package(
99102
"Supabase",
100103
"TestHelpers",
101104
],
102-
resources: [.process("Fixtures")]
105+
resources: [
106+
.process("Fixtures"),
107+
.process("supabase"),
108+
]
103109
),
104110
.target(
105111
name: "PostgREST",
@@ -111,11 +117,13 @@ let package = Package(
111117
.testTarget(
112118
name: "PostgRESTTests",
113119
dependencies: [
120+
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
114121
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
115122
"Helpers",
123+
"Mocker",
116124
"PostgREST",
117-
],
118-
exclude: ["__Snapshots__"]
125+
"TestHelpers",
126+
]
119127
),
120128
.target(
121129
name: "Realtime",
@@ -129,8 +137,8 @@ let package = Package(
129137
name: "RealtimeTests",
130138
dependencies: [
131139
.product(name: "CustomDump", package: "swift-custom-dump"),
132-
.product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay"),
133140
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
141+
.product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay"),
134142
"PostgREST",
135143
"Realtime",
136144
"TestHelpers",
@@ -149,6 +157,9 @@ let package = Package(
149157
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
150158
.product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay"),
151159
"Storage",
160+
],
161+
resources: [
162+
.copy("sadcat.jpg")
152163
]
153164
),
154165
.target(
@@ -174,8 +185,10 @@ let package = Package(
174185
name: "TestHelpers",
175186
dependencies: [
176187
.product(name: "ConcurrencyExtras", package: "swift-concurrency-extras"),
188+
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
177189
.product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay"),
178190
"Auth",
191+
"Mocker",
179192
]
180193
),
181194
]

0 commit comments

Comments
 (0)