I'm writing tests for a project of mine, which involves fixed filepaths and base URLs. To me, the most logic way to define them is by means of public/private constants in a relevant module, but that prevents good testing practices. How can I work around this?
I searched for a possible solution and found that I can define two constructors for a struct in need of a path: one which defines the default path, and another that accepts a custom path
func Construct(param string) MyStruct {
return MyStruct {Param: param, Path: "/default/path"}
}
func ConstructWithPath(param, path string) MyStruct {
return MyStruct {Param: param, Path: path}
}
This is pretty ugly to me and it's a solution tailored exclusively for tests since the paths I'm considering are fixed and known.