The code as written below uploads a file to salesforce, then redirects the user to a specific page.
public class ContentController {
public contentController() {
file = new ContentVersion();
}
public ContentVersion file { get; set; }
public PageReference go() {
insert file;
return new PageReference('** an example url**');
}
}
How can I write an automated unit test to test "uploading a file"? I don't quite get how to do so unless I somehow generate an anonymous file in apex which only works with documents, but not all file types.