Skip to content

Commit 0c96a2e

Browse files
authored
test/golang: Added Golang test code and test case. (#229)
* test: golang 테스트 케이스 추가한다 * chore: print 삭제한다. * chore: 적당한 길이의 테스트케이스로 변경한다 * chore: flake8에 맞춰 코드 정리한다. * chore: 정리 파일에 mod 추가한다. * chore: add reuse license notice for tests/test_mod --------- Signed-off-by: rewrite0w0 <[email protected]> Signed-off-by: Oh TaeJun <[email protected]>
1 parent 74be325 commit 0c96a2e

File tree

4 files changed

+59
-2
lines changed

4 files changed

+59
-2
lines changed

.reuse/dep5

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,8 @@ License: Apache-2.0
120120

121121
Files: tests/test_cargo/*
122122
Copyright: 2024 LG Electronics
123-
License: Apache-2.0
123+
License: Apache-2.0
124+
125+
Files: tests/test_mod/*
126+
Copyright: 2024 junegunn(Junegunn Choi)
127+
License: MIT

tests/pytest/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"tests/result/nuget2",
2323
"tests/result/pub",
2424
"tests/result/pypi",
25-
"tests/result/cargo"
25+
"tests/result/cargo",
26+
"tests/result/mod"
2627
]
2728

2829
remove_directories = set_up_directories
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# Copyright (c) 2024 LG Electronics Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
import os
6+
import pytest
7+
import subprocess
8+
9+
10+
DIST_PATH = os.path.join(os.environ.get("TOX_PATH"), "dist", "cli.exe")
11+
12+
13+
@pytest.mark.parametrize("input_path, output_path, extra_args", [
14+
("tests/test_mod", "tests/result/mod", "-m mod")
15+
])
16+
@pytest.mark.ubuntu
17+
def test_ubuntu(input_path, output_path, extra_args):
18+
command = f"fosslight_dependency -p {input_path} -o {output_path} {extra_args}"
19+
result = subprocess.run(command, shell=True, capture_output=True, text=True)
20+
assert result.returncode == 0, f"Command failed: {command}\nstdout: {result.stdout}\nstderr: {result.stderr}"
21+
assert any(os.scandir(output_path)), f"Output file does not exist: {output_path}"
22+
23+
24+
@pytest.mark.parametrize("input_path, output_path", [
25+
(os.path.join("tests", "test_mod"), os.path.join("tests", "result", "mod")),
26+
])
27+
@pytest.mark.windows
28+
def test_windows(input_path, output_path):
29+
command = f"{DIST_PATH} -p {input_path} -o {output_path}"
30+
result = subprocess.run(command, capture_output=True, text=True)
31+
assert result.returncode == 0, f"Command failed: {command}\nstdout: {result.stdout}\nstderr: {result.stderr}"
32+
assert any(os.scandir(output_path)), f"Output file does not exist: {output_path}"

tests/test_mod/go.mod

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module github.com/junegunn/fzf
2+
3+
require (
4+
github.com/charlievieth/fastwalk v1.0.8
5+
github.com/gdamore/tcell/v2 v2.7.4
6+
github.com/junegunn/go-shellwords v0.0.0-20240813092932-a62c48c52e97
7+
github.com/mattn/go-isatty v0.0.20
8+
github.com/rivo/uniseg v0.4.7
9+
golang.org/x/sys v0.26.0
10+
golang.org/x/term v0.25.0
11+
)
12+
13+
require (
14+
github.com/gdamore/encoding v1.0.0 // indirect
15+
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
16+
github.com/mattn/go-runewidth v0.0.15 // indirect
17+
golang.org/x/text v0.14.0 // indirect
18+
)
19+
20+
go 1.20

0 commit comments

Comments
 (0)