ozontech / allure-go

Complete Allure provider in Go which doesn't overload the interface usage
https://t.me/allure_go_chat
Apache License 2.0
317 stars 34 forks source link

Unable to create a tempDir with long test parameters #49

Closed j-puri closed 1 year ago

j-puri commented 1 year ago

Describe the bug Using the new parameterised tests mechanism I'm unable to create a TempDir() if I use relatively long parameter values. The error reported is file name too long

To Reproduce

package example

import (
    "github.com/ozontech/allure-go/pkg/framework/provider"
    "github.com/ozontech/allure-go/pkg/framework/suite"
    "testing"
)

type TestParams struct {
    arg1 string
    arg2 string
    arg3 string
    arg4 string
    arg5 string
    arg6 string
}

type ParametrizedSuite struct {
    suite.Suite
    ParamLongParams []TestParams
}

func (s *ParametrizedSuite) BeforeAll(t provider.T) {
    s.ParamLongParams = []TestParams{
        {
            arg1: "I am a long string used as arg1",
            arg2: "I am a long string used as arg2",
            arg3: "I am a long string used as arg3",
            arg4: "I am a long string used as arg4",
            arg5: "I am a long string used as arg5",
            arg6: "I am a long string used as arg6",
        },
    }
}

func (s *ParametrizedSuite) TableTestLongParams(t provider.T, params TestParams) {
    t.Parallel()
    t.TempDir()
    t.Require().NotEmpty(params)
}

func TestNewParametrizedDemo(t *testing.T) {
    suite.RunSuite(t, new(ParametrizedSuite))
}

Expected behavior The test name is truncated to create a temp directory.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context output:


/usr/local/go/bin/go tool test2json -t /private/var/folders/_0/4m7k4wy15ygb4wwsj4jbfyc00000gp/T/dlvLauncher2.sh /Users/jaspal.puri/Library/Application Support/JetBrains/Toolbox/apps/Goland/ch-0/223.8214.59/GoLand.app/Contents/plugins/go-plugin/lib/dlv/mac/dlv --listen=127.0.0.1:57440 --headless=true --api-version=2 --check-go-version=false --only-same-user=false exec /private/var/folders/_0/4m7k4wy15ygb4wwsj4jbfyc00000gp/T/GoLand/___1TestNewParametrizedDemo_in_github_dns_ad_zopa_com_zopaUK_devx_system_tests_system_tests.test -- -test.v -test.paniconexit0 -test.run ^\QTestNewParametrizedDemo\E$
=== RUN   TestNewParametrizedDemo
=== RUN   TestNewParametrizedDemo/ParametrizedSuite
=== RUN   TestNewParametrizedDemo/ParametrizedSuite/BeforeAll
=== RUN   TestNewParametrizedDemo/ParametrizedSuite/Tests
=== RUN   TestNewParametrizedDemo/ParametrizedSuite/Tests/LongParams_{arg1:I_am_a_long_string_used_as_arg1_arg2:I_am_a_long_string_used_as_arg2_arg3:I_am_a_long_string_used_as_arg3_arg4:I_am_a_long_string_used_as_arg4_arg5:I_am_a_long_string_used_as_arg5_arg6:I_am_a_long_string_used_as_arg6}
=== PAUSE TestNewParametrizedDemo/ParametrizedSuite/Tests/LongParams_{arg1:I_am_a_long_string_used_as_arg1_arg2:I_am_a_long_string_used_as_arg2_arg3:I_am_a_long_string_used_as_arg3_arg4:I_am_a_long_string_used_as_arg4_arg5:I_am_a_long_string_used_as_arg5_arg6:I_am_a_long_string_used_as_arg6}
=== CONT  TestNewParametrizedDemo/ParametrizedSuite/Tests/LongParams_{arg1:I_am_a_long_string_used_as_arg1_arg2:I_am_a_long_string_used_as_arg2_arg3:I_am_a_long_string_used_as_arg3_arg4:I_am_a_long_string_used_as_arg4_arg5:I_am_a_long_string_used_as_arg5_arg6:I_am_a_long_string_used_as_arg6}
    test_example_test.go:37: TempDir: mkdir /var/folders/_0/4m7k4wy15ygb4wwsj4jbfyc00000gp/T/TestNewParametrizedDemoParametrizedSuiteTestsLongParams_{arg1I_am_a_long_string_used_as_arg1_arg2I_am_a_long_string_used_as_arg2_arg3I_am_a_long_string_used_as_arg3_arg4I_am_a_long_string_used_as_arg4_arg5I_am_a_long_string_used_as_arg5_arg6I_am_a_long_string_used_as_arg6}51418563: file name too long
--- FAIL: TestNewParametrizedDemo (0.00s)
    --- FAIL: TestNewParametrizedDemo/ParametrizedSuite (0.00s)
        --- PASS: TestNewParametrizedDemo/ParametrizedSuite/BeforeAll (0.00s)
        --- FAIL: TestNewParametrizedDemo/ParametrizedSuite/Tests (0.00s)
            --- FAIL: TestNewParametrizedDemo/ParametrizedSuite/Tests/LongParams_{arg1:I_am_a_long_string_used_as_arg1_arg2:I_am_a_long_string_used_as_arg2_arg3:I_am_a_long_string_used_as_arg3_arg4:I_am_a_long_string_used_as_arg4_arg5:I_am_a_long_string_used_as_arg5_arg6:I_am_a_long_string_used_as_arg6} (0.00s)

FAIL

Debugger finished with the exit code 0```
nugolnikova commented 1 year ago

Added trimming of the parametrized test name to 150 characters.

By default, the test name was concatenated from the values of your structure arguments. You can override the String() method for your structure, so that it returns a shorter and more informative name. Example: func (t TestParams) String() string { return "short informative name" }