Discourse’s handling of BBCode is a little bit different, but if you put the [code] on a line by itself, with blank lines before it and after the closing [/code], it should work fine.
But you can also use Github style Markdown, with three backticks:
```
Test
```
Produces
Test
Lastly, indenting with four spaces also does a code block.
Test
I like the triple backtick option most, but YMMV.