module retrievalfixtures import os pub struct Reply { pub: status int = -1 data []u8 } pub struct Call { pub: url string filename string force bool trailing_slash bool } pub struct Plan { pub mut: replies map[string]Reply calls []Call } pub fn (mut plan Plan) fetch(url string, directory string, filename string, force bool) int { plan.calls << Call{ url: url, filename: filename, force: force, trailing_slash: directory.ends_with('/') } reply := plan.replies[url] or { return -1 } if reply.status == 0 { os.write_file_array(os.join_path(directory, filename), reply.data) or { eprintln(err) return -1 } } return reply.status }