Fork me on GitHub
#polylith
<
2023-01-06
>
Jungin Kwon11:01:32

Where should I put test resources in components?

Jungin Kwon11:01:13

This is the structure I am using,

components/
	{my-component}/
		src/
		test/
			{top-namepsace}/
				{my-component}/
			test-resources/
				(resources for test only)
		deps.edn
in deps.edn
:aliases {:test {:extra-paths ["test"]

Jungin Kwon11:01:23

poly check gives me, Warning 205: Non top namspace test-resources was found in {my-component}.

pavlosmelissinos12:01:56

Putting it alongside test is more common in Clojure-land, I think the same is true specifically for polylith. E.g.:

components/
	{my-component}/
		src/
		test/
			{top-namepsace}/
				{my-component}/
		test-resources/
			(resources for test only)
		deps.edn
:aliases {:test {:extra-paths ["test" "test-resources"]

Jungin Kwon12:01:14

Still getting same warning 😿

😞 2
pavlosmelissinos14:01:22

You're getting the same warning? Are you sure?

pavlosmelissinos14:01:10

If you've added test-resources to the classpath, it shouldn't be the top namespace anymore. I'm surprised you're seeing the same warning as before. If it's not exactly the same (i.e. different top namespace), do you happen to have any .clj* files in test-resources by any chance?

tengstrand15:01:17

The problem is that the poly tool checks for non top namespaces in all directories, except if they have the name resources which means that you will get this warning right now, even though test-resources is also a resources directory. You can verify that by typing:

poly ws get:components:my-component:non-top-namespaces
…and it will list the directories in test-resources that it thinks are top namespaces. A solution could be to also treat test-resources as a resources directory, and skip it in the 205 warning. I can create an issue.

2
seancorfield19:01:29

I put these things under test/top-ns/* alongside the test source

tengstrand11:01:48

When I think about it, I think that is a good solution (what Sean suggests) so I will close issue 276 for now at least.

Jungin Kwon13:01:38

Thank you! 💓

👍 2
Jungin Kwon02:01:20

@U04V70XH6 Then, do you access all the test resource files through the path with the underbar?

seancorfield05:01:28

Via whatever is the correct classpath-relative path... (Guess I'm not really sure what you're asking?).

tengstrand08:01:02

What you can do also @U027B5AEPCG if you want to separate the resources from the source files, you can add one more source test directory test-resources and then add it to deps.edn e.g. :aliases {:test {:extra-paths ["test" "test-resources"].

👍 2