Skip to content

Commit 31ff8a2

Browse files
authored
Merge pull request #685 from meilisearch/feat/update-index-swap
Fix index swap tests
2 parents df6c2b0 + 9a81717 commit 31ff8a2

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

.cursor/rules/general.mdc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
alwaysApply: true
3+
---
4+
5+
- Use Docker for local development
6+
- Run tests with `docker-compose run --rm package bash -c "dotnet test && dotnet format --verbosity normal --verify-no-changes"`

.github/workflows/tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ jobs:
2727
- name: Build
2828
run: dotnet build --configuration Release --no-restore
2929
- name: Meilisearch (latest version) setup with Docker
30+
env:
31+
# Any docker tag is actually accepted as a valid version
32+
MEILISEARCH_VERSION: latest
3033
run: docker compose up -d
3134
- name: Run tests
3235
run: dotnet test --no-restore --verbosity normal

src/Meilisearch/IndexSwap.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@ public class IndexSwap
1111
[JsonPropertyName("indexes")]
1212
public List<string> Indexes { get; private set; }
1313

14-
public IndexSwap(string indexA, string indexB)
14+
[JsonPropertyName("rename")]
15+
public bool Rename { get; set; } = false;
16+
17+
public IndexSwap(string indexA, string indexB, bool rename = false)
1518
{
1619
this.Indexes = new List<string> { indexA, indexB };
20+
this.Rename = rename;
1721
}
1822
}
1923
}

tests/Meilisearch.Tests/IndexSwapTest.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ public void CreateExpectedJSONFormat()
2222

2323
var json = JsonSerializer.Serialize(swap);
2424
Assert.Contains("\"indexes\":[\"indexA\",\"indexB\"]", json);
25+
Assert.Contains("\"rename\":false", json);
26+
}
27+
28+
[Fact]
29+
public void CreateExpectedJSONFormatWithRenameTrue()
30+
{
31+
var swap = new IndexSwap("indexA", "indexB", rename: true);
32+
33+
var json = JsonSerializer.Serialize(swap);
34+
Assert.Contains("\"indexes\":[\"indexA\",\"indexB\"]", json);
35+
Assert.Contains("\"rename\":true", json);
2536
}
2637
}
2738
}

0 commit comments

Comments
 (0)