What idempotent command can I use to make a symlink pointing to a directory?

You should use the -T option for this, it tells ln to always treat the link name as the desired link name, never as a directory.

Without this option, if you give ln a link name which exists as a directory, it creates a new link to the target inside that directory.

Note that -T is a GNU-ism (at least, it’s not in POSIX), but you’re already using -v which is a GNU-ism too so I imagine that’s not an issue.

Alternatively, you can just specify the parent directory as the link name, and the link will always be (re-)created there:

ln -sfv /tmp/test_symlink/repo/resources/snippets /tmp/test_symlink/foo/

This works because your symlink has the same name as the target.