Repository: Dorukyum/pycord-multicog (language: python)

Issue:
Automated tests
Automated tests and a workflow to make sure multicog is applied correctly.


Discussion / hints:

Fix patch:
diff --git a/.gitignore b/.gitignore
index a6efe5c..e12ee42 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,4 @@
 **.egg-info
 **/dist
 **/build
-**/__pycache__
-test.py
\ No newline at end of file
+**/__pycache__
\ No newline at end of file


Test patch:
diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml
new file mode 100644
index 0000000..0bf4e91
--- /dev/null
+++ b/.github/workflows/python-test.yml
@@ -0,0 +1,25 @@
+name: Test Library
+
+on: push
+
+jobs:
+  test:
+
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        python-version: ["3.8", "3.9", "3.10"]
+
+    steps:
+      - uses: actions/checkout@v3
+      - name: Set up Python ${{ matrix.python-version }}
+        uses: actions/setup-python@v4
+        with:
+          python-version: ${{ matrix.python-version }}
+      - name: Install dependencies
+        run: |
+          python -m pip install --upgrade pip
+          pip install pytest py-cord
+      - name: Test with pytest
+        run: |
+          pytest test.py
diff --git a/test.py b/test.py
new file mode 100644
index 0000000..45d90e4
--- /dev/null
+++ b/test.py
@@ -0,0 +1,35 @@
+import discord
+
+from pycord.multicog import apply_multicog, add_to_group
+
+
+def test_multicog():
+    bot = discord.Bot()
+
+    class FirstCog(discord.Cog):
+        group = discord.SlashCommandGroup("group")
+
+        @group.command()
+        async def dummy(self, ctx):
+            await ctx.respond("I am a dummy command.")
+
+    class SecondCog(discord.Cog):
+        @add_to_group("group")
+        @discord.slash_command()
+        async def test_command(self, ctx):
+            await ctx.respond(f"I am inside the cog `{self.__class__.__name__}`.")
+
+    bot.add_cog(FirstCog())
+    bot.add_cog(SecondCog())
+
+    apply_multicog(bot)
+
+    assert isinstance(
+        (group := bot.pending_application_commands[0]), discord.SlashCommandGroup
+    )
+    assert (test_command := group.subcommands[-1]).name == "test_command"
+    assert test_command.parent is not None and test_command.parent == group
+
+
+if __name__ == "__main__":
+    test_multicog()